<!--#include file="../../conn/conn_other.asp"-->
<!--#include file="../check.asp"-->
<!--#include file="../../inc/setup.asp"-->
<!--#include file="../../film/Incs/syscode.asp"-->
<!--#include file="../../inc/sql.asp"-->
<%
	end if
	WebName=homename
	WebKey=webmeta
	WebDes=webmeta1
	WebUrl=homeurl
	useflag=1
%>
<!--#include file="../flag.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Html生成页</title>
<link href="css/Admin_Style.Css" rel="stylesheet">
<link href='../Include/Admin_Style.CSS' rel='stylesheet' type='text/css'>
<script language="javascript" src="js/Admin_Js.js"></script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="sortbutton">
<tr>    
<td height="23" align="center" valign="middle">视频生成管理</td>
</tr>
</table>
<%
Server.ScriptTimeout=99999999
Dim Action
Action=CheckStr(Request("Action"))
Select Case Action
	Case "Index"
		Call IndexMake()
	Case "Class"
		Call ClassForm()
	Case "ClassMake"
		Call ClassMake()	
	Case "Video"
		Call VideoForm()
	Case "VideoMake"
		Call VideoMake()
	Case "SiteMap"
		Call SiteMapMake()
End Select

Function IndexMake()
	Dim Url,HtmlCode,Fso
	Url=GetUrl()
	
	Url=Replace(Url,SplitStr(Url,"/",2),"")
	Url=Replace(Url,SplitStr(Url,"/",3)&"/","")
	Url=Url&"film/"&Replace(TempDir,"../","")&"Index.asp"
	HtmlCode=GetHttpPage(Url,"GB2312")
	Set Fso=New DmFso
		Call Fso.CreateFile("/film/Index.html",HtmlCode,True)
	Set Fso=Nothing
	Call LoadingBar("Admin_MakeHtml.asp?Action=Index")
	Rw "<script>loadtb.style.width=400;loadtxt.innerHTML=""完成100% 生成网站首页成功！ 首页地址:<a href='/film/Index.html' target='_blank'>/film/Index.html</a>"";loadtb.title=""(100)"";</script>"
End Function
%>
<%
Function SiteMapMake()
	Dim Url,HtmlCode,Fso
	Url=GetUrl()
	Url=Replace(Url,SplitStr(Url,"/",2),"")
	Url=Replace(Url,SplitStr(Url,"/",3)&"/","")
	Url=Url&"film/"&Replace(TempDir,"../","")&"SiteMap.asp"
	HtmlCode=GetHttpPage(Url,"GB2312")
	Set Fso=New DmFso
		Call Fso.CreateFile("/film/SiteMap.html",HtmlCode,True)
	Set Fso=Nothing
	Call LoadingBar("Admin_MakeHtml.asp?Action=SiteMap")
	Rw "<script>loadtb.style.width=400;loadtxt.innerHTML=""完成100% 生成网站地图成功！ 首页地址:<a href='/film/SiteMap.html' target='_blank'>/film/SiteMap.html</a>"";loadtb.title=""(100)"";</script>"
End Function
%>
<%
Function ClassForm()
	'Call LoadTempLate("TempListCode",""&TempDir&"List.html")
	Call LoadTempLate("TempListCode","List.html")
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
<form name="test" method="post" action="?Action=ClassMake">
  <tr>
    <td colspan="2" class="title">生成网站分类</td>
    </tr>
  <tr>
    <td width="17%" class="tbove">请选择要生成的分类：</td>
    <td width="83%" class="tbove"><%=GetClassSelect(0,0)%>
      <input name="button" type="submit" class="button" id="button" value="生成分类列Html" /></td>
  </tr>
</form>
</table>
<%
End Function

Function ClassMake()
	Dim StartID,EndID,ID,ClassID
	ClassID=CheckNum(Request("ClassID"))
	If ClassID=0 Then
		StartID=DBGetNum("Dm_Class","ClassID",2)
		EndID=DBGetNum("Dm_Class","ClassID",1)
	Else
		StartID=ClassID
		EndID=ClassID
	End If
	ID=CheckNum(Request("ID"))
	If ID=0 Then ID=StartID
	'/读取分类名称
	Dim Rs,Sql
	Sql="Select ClassName,ClassEName From Dm_Class Where ClassID="&ID&""
	Set Rs=Conn.ExeCute(Sql)
	If Rs.Bof And Rs.Eof Then
		Rw ("")
	Else
		ClassName=Rs("ClassName")
		ClassEName=Rs("ClassEName")
	End If
	Rs.Close
	Set Rs=Nothing
	If ClassName<>"" And ClassEName<>"" Then
		'/读取该分类视频总数和总页数
		Dim TempStr
		Dim Countmax,PageMax
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Sql="Select VideoID From Dm_Video Where ClassID="&ID&" Order By VideoID Desc"
		Rs.Open Sql,Conn,1,1
		If Rs.Bof And Rs.Eof Then
			Countmax=0
			PageMax=1
		Else
			Countmax=Rs.RecordCount
			PageMax=Int((CountMax-1)/HtmlListNum)+1
		End If
		'/循环页数读取数据
		Dim I
		For I = 1 To PageMax
			'/读取分页的数据
			Set Rs=Server.CreateObject("Adodb.Recordset")
			Sql="Select A.*,B.ClassName,B.ClassEName From Dm_Video As A,Dm_Class As B Where A.ClassID=B.ClassID And A.ClassID="&ID&" Order By A.PostTime Desc"
			Rs.Open Sql,Conn,1,1
			If Rs.Bof And Rs.Eof Then
				'/读取模版
				Dim OutCode
				OutCode=Application("TempListCode")
				'/替换模版
				OutCode=Replace(OutCode,"{Dm_WebName}",WebName)
				OutCode=Replace(OutCode,"{Dm_PageTitle}","")
				OutCode=Replace(OutCode,"{Dm_Meta}",WebKey)
				OutCode=Replace(OutCode,"{Dm_Desc}",WebDes)
				OutCode=Replace(OutCode,"{Dm_ClassName}",ClassName)
				OutCode=Replace(OutCode,"{Dm_ClassID}",ID)
				OutCode=Replace(OutCode,"{Dm_ClassEName}",ClassEName)
				OutCode=Replace(OutCode,"{Dm_WebUrl}",WebUrl)
				OutCode=Replace(OutCode,"{Dm_Channel}",GetChannelList(ID,1))
				OutCode=Replace(OutCode,"{Dm_NavBar}",">><a href=""/film/film/"&GetClassPath(ID,ClassEName)&""">"&ClassName&"</a>")
				OutCode=Replace(OutCode,"{Dm_VideoList}","")
				OutCode=Replace(OutCode,"{Dm_ShowPage}","")
				OutCode=Replace(OutCode,"{Dm_ComVideo}","")
				OutCode=Replace(OutCode,"{Dm_HitsVideo}","")
				OutCode=Replace(OutCode,"{Dm_CopyRight}",WebCopy)
				'/生成Html
				Dim Fso,HtmlPageName,HtmlSaveDir
				HtmlPageName="Index.html"
				HtmlSaveDir="/film/film/"&GetClassPath(ID,ClassEName)
				Set Fso=New DmFso
				If Fso.CheckFolder(HtmlSaveDir)=False Then
					Call Fso.CreateFolder(HtmlSaveDir)
				End If
				Call Fso.CreateFile(HtmlSaveDir&HtmlPageName,OutCode,True)
				Set Fso=Nothing
				'/*输出结果*/
				'Rf ("<li><a href="&HtmlSaveDir&HtmlPageName&" target='_blank'>"&HtmlSaveDir&HtmlPageName&"生成完毕！</a></li>")&vbcrlf
			Else
				Rs.PageSize=HtmlListNum
				Rs.AbsolutePage=I
				'/读取该页视频列表
				Dim ListStr
				ListStr=""
				ListStr=ListStr&"<ul>"&vbcrlf
				A=0
				Do While Not Rs.Eof And A<HtmlListNum
					VideoPic=Rs("VideoPic")
					If InStr(VideoPic,"http")>0 Then
						VideoPic=VideoPic
					Else
						VideoPic="/film/film/"&VideoPic
					End If
					ListStr=ListStr&"<li><a href=""/film/film/"&GetClassPath(Rs("ClassID"),Rs("ClassEName"))&GetVideoPath(Rs("VideoID"),Rs("VideoEName"))&""" title="""&Rs("VideoName")&""" target=""_blank""><img src="""&VideoPic&""" alt="""&Rs("VideoName")&""" onerror=""this.src='/film/Images/error.gif'""></a><p class=""t""><a href=""/film/film/"&GetClassPath(Rs("ClassID"),Rs("ClassEName"))&GetVideoPath(Rs("VideoID"),Rs("VideoEName"))&""" title="""&Rs("VideoName")&""" target=""_blank"">"&Rs("VideoName")&"</a></p><p>主演："&LeftStr(Rs("Player"),24)&"</p><p>分类："&Rs("ClassName")&"</p><p>时间："&FormatTime(Rs("PostTime"),4)&"</p></li>"&vbcrlf
				A=A+1
				Rs.MoveNext
				Loop
				ListStr=ListStr&"</ul>"&vbcrlf
				'Rw("<textarea cols=100 rows=10>"&ListStr&"</textarea>")
				'/分页代码
				Dim PageStr
				PageStr=""
				PageStr=PageStr&"共有"&Countmax&"条 每页"&HtmlListNum&"条 "&I&"/"&PageMax&" "
				If I=1 Then
					PageStr=PageStr&""&vbcrlf
				ElseIf I=2 Then
					PageStr=PageStr&"<a href=""Index.html"" title=""第一页""><<</a>"&vbcrlf
					PageStr=PageStr&"<a href=""Index.html"" title=""上一页""><</a>"&vbcrlf
				Else
					PageStr=PageStr&"<a href=""Index.html"" title=""第一页""><<</a>"&vbcrlf
					PageStr=PageStr&"<a href=""List_"&I-1&".html"" title=""上一页""><</a>"&vbcrlf
				End If
				Dim D,PageStart,PageEnd,LinkNum
				LinkNum=5
				If I<=LinkNum Then
					PageStart=1
					PageEnd=LinkNum*2+1
				Else
					PageStart=I-LinkNum
					PageEnd=I+LinkNum
				End If
				For D=PageStart To PageEnd
					If D>0 And D<=PageMax Then
						If D<>I Then
							If D=1 Then
								PageStr=PageStr&"<a href=""Index.html"" title=""第"&D&"页"">"&D&"</a>"&vbcrlf
							Else
								PageStr=PageStr&"<a href=""List_"&D&".html"" title=""第"&D&"页"">"&D&"</a>"&vbcrlf
							End If
						Else
							If D=1 Then
								PageStr=PageStr&"<a href=""Index.html"" class=""on"" title=""第"&D&"页"">"&D&"</a>"&vbcrlf
							Else
								PageStr=PageStr&"<a href=""List_"&D&".html"" class=""on"" title=""第"&D&"页"">"&D&"</a>"&vbcrlf
							End If
						End If
					End If
				Next
				If I<PageMax Then
					PageStr=PageStr&"<a href=""List_"&I+1&".html"" title=""下一页"">></a>"&vbcrlf
					PageStr=PageStr&"<a href=""List_"&PageMax&".html"" title=""最后一页"">>></a>"&vbcrlf
				End If
				'/获取该分类相关视频
				Dim ComVideo,HitsVideo
				ComVideo=GetTopVideo(HtmlTjNum,"And A.ClassID="&ID&"",3,False,False,True,20,1)
				HitsVideo=GetTopVideo(HtmlHitNum,"And A.ClassID="&ID&"",2,False,False,True,20,1)
				'/读取模版
				OutCode=Application("TempListCode")
				'/替换模版
				OutCode=Replace(OutCode,"{Dm_WebName}",WebName)
				OutCode=Replace(OutCode,"{Dm_PageTitle}",ClassName)
				OutCode=Replace(OutCode,"{Dm_Meta}",WebKey)
				OutCode=Replace(OutCode,"{Dm_Desc}",WebDes)
				OutCode=Replace(OutCode,"{Dm_ClassName}",ClassName)
				OutCode=Replace(OutCode,"{Dm_ClassID}",ID)
				OutCode=Replace(OutCode,"{Dm_ClassEName}",ClassEName)
				OutCode=Replace(OutCode,"{Dm_WebUrl}",WebUrl)
				OutCode=Replace(OutCode,"{Dm_Channel}",GetChannelList(ID,1))
				OutCode=Replace(OutCode,"{Dm_NavBar}",">><a href=""/film/film/"&GetClassPath(ID,ClassEName)&""">"&ClassName&"</a>")
				OutCode=Replace(OutCode,"{Dm_VideoList}",ListStr)
				OutCode=Replace(OutCode,"{Dm_ShowPage}",PageStr)
				OutCode=Replace(OutCode,"{Dm_ComVideo}",ComVideo)
				OutCode=Replace(OutCode,"{Dm_HitsVideo}",HitsVideo)
				OutCode=Replace(OutCode,"{Dm_CopyRight}",WebCopy)
				'/生成Html
				If I=1 Then
					HtmlPageName="Index.html"
				Else
					HtmlPageName="List_"&I&".html"
				End If
				HtmlSaveDir="/film/film/"&GetClassPath(ID,ClassEName)
				Set Fso=New DmFso
				If Fso.CheckFolder(HtmlSaveDir)=False Then
					Call Fso.CreateFolder(HtmlSaveDir)
				End If
				Call Fso.CreateFile(HtmlSaveDir&HtmlPageName,OutCode,True)
				Set Fso=Nothing
				'/*输出结果*/
				'Rf ("<li><a href="&HtmlSaveDir&HtmlPageName&" target='_blank'>"&HtmlSaveDir&HtmlPageName&"生成完毕！</a></li>")&vbcrlf
			End If
			Rs.Close
			Set Rs=Nothing
		Next
	End If
	'/*进度条*/
	Dim TotalNum,BiLi,TabWidth
	TotalNum=EndID-StartID+1
	NowID=ID-StartID+1
	BiLi=Formatnumber((ID/EndID)*100,2)
	TabWidth=Int(400*(ID/EndID))
	Call LoadingBar("Admin_MakeHtml.asp?Action=Class")
	Rf "<script>loadtb.style.width="&TabWidth&";loadtxt.innerHTML=""完成："&BiLi&"%  共有分类"&TotalNum&"个 　正在生成第<font color='red'>"&NowID&"</font>个分类 "";loadtb.title=""("&BiLi&")"";</script>"
	'/*继续生成下一分类*/
	If ID<EndID Then
		Rw ("<meta http-equiv=Refresh content='1; URL=?Action=ClassMake&StartID="&StartID&"&EndID="&EndID&"&ID="&Clng(ID) + 1 &"'>")
	Else
		Rw ("<script>gID('backb').value='全部生成完毕';</script>")
	End If
End Function

Function VideoForm()
	Call LoadTempLate("TempShowCode","Show.html")
	Call LoadTempLate("TempPlayCode","Play.html")
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
  <tr>
    <td class="title">生成网站视频</td>
    </tr>
<form name="test" method="post" action="?Action=VideoMake">
  <tr>
    <td class="tabletd tl">① 按分类生成
      <input name="sType" type="hidden" id="sType" value="1" /></td>
  </tr>
  <tr>
    <td class="tbove">请选择要生成视频的分类：<%=GetClassSelect(0,1)%>
      <input name="button2" type="submit" class="button" id="button2" value="生成视频Html" /></td>
    </tr>
</form>
<form name="test" method="post" action="?Action=VideoMake">
  <tr>
    <td class="tabletd tl">② 按开始ID和结束ID生成
      <input name="sType" type="hidden" id="sType" value="2" /></td>
  </tr>
  <tr>
    <td class="tbove">请输入要生成的ID：
      开始ID：<input name="StartID" type="text" class="text" id="StartID" size="8" value="<%=DBGetNum("Dm_Video","VideoID",2)%>" />
      结束ID：<input name="EndID" type="text" class="text" id="EndID" size="8" value="<%=DBGetNum("Dm_Video","VideoID",1)%>"/>
      <input name="submit" type="submit" class="button" id="submit" value="开始生成" />
     </td>
    </tr>
</form>
<form name="test" method="post" action="?Action=VideoMake">
  <tr>
    <td class="tabletd tl">② 按日期生成
      <input name="sType" type="hidden" id="sType" value="3" /></td>
  </tr>
  <tr>
    <td class="tbove">请选择日期：
      <%
	  Dim nYear,nMonth,nDay
	  nYear=Year(Now())
	  nMonth=Month(Now())
	  nDay=Day(Now())
	  %>
      <select name="sYear" id="sYear">
      <%
	  For I = 2001 To nYear
	  %>
      <option value="<%=I%>" <%If I=nYear Then Rw("selected")%>><%=I%></option>
      <%
	  Next
	  %>
      </select>
      年
      <select name="sMonth" id="sMonth">
      <%
	  For I = 1 To 12
	  %>
      <option value="<%=I%>" <%If I=nMonth Then Rw("selected")%>><%=I%></option>
      <%
	  Next
	  %>
      </select>
      月 
      <select name="sDay" id="sDay">
      <%
	  For I = 1 To 31
	  %>
      <option value="<%=I%>" <%If I=nDay Then Rw("selected")%>><%=I%></option>
      <%
	  Next
	  %>
      </select>
      日 
      <input name="submit" type="submit" class="button" id="submit" value="开始生成" />
      </td>
    </tr>
</form>
</table>
<%
End Function

Function VideoMake()
	Dim StartID,EndID,ID,ClassID,sType
	sType=CheckNum(Request("sType"))
	If sType=1 Then
	'/*-------------------按分类生成----------------------*/
		'/*进度条*/
		Call LoadingBar("Admin_MakeHtml.asp?Action=Video")
		ClassID=CheckNum(Request("ClassID"))
		Dim Rs,Sql,vCount
		Set Rs=Server.CreateObject("Adodb.Recordset")
		Sql="Select VideoID From Dm_Video Where ClassID="&ClassID&""
		Rs.Open Sql,Conn,1,1
		If Rs.Bof And Rs.Eof Then
			vCount=0
			Rf "<script>loadtb.style.width=400;loadtxt.innerHTML=""完成：100%  共有数据"&vCount&"个 　正在生成第<font color='red'>0</font>条数据 "";loadtb.title=""(100)"";</script>"
		Else
			vCount=Rs.RecordCount
			For I = 1 To vCount
				If Not Rs.Eof Then
					Call VideoMakeHtml(Rs("VideoID"))
					Rs.MoveNext
				End If
				'/*显示进度*/
				Dim BiLi,TabWidth,NowID
				NowID=I
				BiLi=Formatnumber((I/vCount)*100,2)
				TabWidth=Int(400*(I/vCount))
				Rf "<script>loadtb.style.width="&TabWidth&";loadtxt.innerHTML=""完成："&BiLi&"%  共有数据"&vCount&"个 　正在生成第<font color='red'>"&NowID&"</font>条数据 "";loadtb.title=""("&BiLi&")"";</script>"
				If I=vCount Then Rf ("<script>gID('backb').value='全部生成完毕';</script>")
			Next
		End If
		Rs.Close
		Set Rs=Nothing
	ElseIf sType=2 Then
	'/*-----------------按开始结束ID生成-------------------*/
		'/*进度条*/
		Call LoadingBar("Admin_MakeHtml.asp?Action=Video")
		StartID=CheckNum(Request("StartID"))
		EndID=CheckNum(Request("EndID"))
		ID=CheckNum(Request("ID"))
		If ID=0 Then ID=StartID
		Call VideoMakeHtml(ID)
		'/*显示进度*/
		TotalNum=EndID-StartID+1
		NowID=ID-StartID+1
		BiLi=Formatnumber((ID/EndID)*100,2)
		TabWidth=Int(400*(ID/EndID))
		Rf "<script>loadtb.style.width="&TabWidth&";loadtxt.innerHTML=""完成："&BiLI&"%  共有数据"&TotalNum&"条 　正在生成第<font color='red'>"&NowID&"</font>条 "";loadtb.title=""("&BiLi&")"";</script>"
		If ID<EndID Then
			Rw ("<meta http-equiv=Refresh content='0; URL=?Action=VideoMake&sType=2&StartID="&StartID&"&EndID="&EndID&"&ID="&Clng(ID) + 1 &"'>")
		Else
			Rw ("<script>gID('backb').value='全部生成完毕';</script>")
		End If
	ElseIf sType=3 Then
	'/*---------------------按时间生成---------------------*/
		'/*进度条*/
		Call LoadingBar("Admin_MakeHtml.asp?Action=Video")
		Dim sTime
		sTime=Request("sYear")&"-"&Request("sMonth")&"-"&Request("sDay")
		Set Rs=Server.CreateObject("Adodb.Recordset")
		Sql="Select VideoID From Dm_Video Where Datediff('d',PostTime,'"&sTime&"')=0"
		Rs.Open Sql,Conn,1,1
		If Rs.Bof And Rs.Eof Then
			vCount=0
			Rf "<script>loadtb.style.width=400;loadtxt.innerHTML=""完成：100%  共有数据"&vCount&"个 　正在生成第<font color='red'>0</font>条数据 "";loadtb.title=""(100)"";</script>"
		Else
			vCount=Rs.RecordCount
			For I = 1 To vCount
				If Not Rs.Eof Then
					Call VideoMakeHtml(Rs("VideoID"))
					Rs.MoveNext
				End If
				'/*显示进度*/
				NowID=I
				BiLi=Formatnumber((I/vCount)*100,2)
				TabWidth=Int(400*(I/vCount))
				Rf "<script>loadtb.style.width="&TabWidth&";loadtxt.innerHTML=""完成："&BiLi&"%  共有数据"&vCount&"个 　正在生成第<font color='red'>"&NowID&"</font>条数据 "";loadtb.title=""("&BiLi&")"";</script>"
				If I=vCount Then Rf ("<script>gID('backb').value='全部生成完毕';</script>")
			Next
		End If
		Rs.Close
		Set Rs=Nothing
	ElseIf sType=4 Then
		'/*---------------------按选择的ID生成---------------------*/
		'/*进度条*/
		Call LoadingBar("Admin_Video.asp")
		Dim VideoID
		VideoID=Request("VideoID")
		If VideoID="" Then Call ShowErr("请选择要生成的ID!")
		If InStr(VideoID,",")>0 Then
			Dim Key
			Key=Split(VideoID,",")
			For I = 0 To Ubound(Key)
				If Key(I)<>"" And IsNull(Key(I))=False Then
					Call VideoMakeHtml(Key(I))
				End If
				'/*显示进度*/
				NowID=I
				BiLi=Formatnumber((I/Ubound(Key))*100,2)
				TabWidth=Int(400*(I/Ubound(Key)))
				Rf "<script>loadtb.style.width="&TabWidth&";loadtxt.innerHTML=""完成："&BiLi&"%  共有数据"&Ubound(Key)+1&"个 　正在生成第<font color='red'>"&NowID+1&"</font>条数据 "";loadtb.title=""("&BiLi&")"";</script>"
				If I=Ubound(Key) Then Rf ("<script>gID('backb').value='全部生成完毕';</script>")
			Next
		Else
			Call VideoMakeHtml(VideoID)
			'/*显示进度*/
			NowID=I
			BiLi=100
			TabWidth=400
			Rf "<script>loadtb.style.width="&TabWidth&";loadtxt.innerHTML=""完成："&BiLi&"%  共有数据1个 　正在生成第<font color='red'>1</font>条数据 "";loadtb.title=""("&BiLi&")"";</script>"
			Rf ("<script>gID('backb').value='全部生成完毕';</script>")
		End If
	ElseIf sType=5 Then
		'/*---------------------按选择的单个ID生成---------------------*/
		Call LoadingBar("Admin_Video.asp")
		VideoID=Request("ID")
		Call VideoMakeHtml(VideoID)
		'/*显示进度*/
		BiLi=100
		TabWidth=400
		Rf "<script>loadtb.style.width="&TabWidth&";loadtxt.innerHTML=""完成："&BiLi&"%  共有数据1个 　正在生成第<font color='red'>1</font>条数据 "";loadtb.title=""("&BiLi&")"";</script>"
		Rf ("<script>gID('backb').value='全部生成完毕';</script>")
		Rf ("<script>location.href='"&Request.ServerVariables("HTTP_REFERER")&"';</script>")
	End If
End Function

Function VideoMakeHtml(VideoID)
	Dim Rs,Sql
	Sql="Select A.*,B.ClassName,B.ClassEName From Dm_Video As A,Dm_Class As B Where A.ClassID=B.ClassID And A.VideoID="&VideoID&""
	Set Rs=Conn.Execute(Sql)
	If Not(Rs.Bof And Rs.Eof) Then 
		'/*-----------生成内容页-----------*/
		Dim VideoName,VideoENameVideoPic,Player,PlayType
		Dim PlayUrl,PlayType2,PlayUrl2,Content,PostTime
		Dim ClassID,ClassName,ClassEName
		ClassID=Rs("ClassID")
		ClassName=Rs("ClassName")
		ClassEName=Rs("ClassEName")
		VideoName=Rs("VideoName")
		VideoEName=Rs("VideoEName")
		VideoState=Rs("VideoState")
		VideoPic=Rs("VideoPic")
		Player=Rs("Player")
		PlayType=Rs("PlayType")
		PlayUrl=Rs("PlayUrl")
		PlayType2=Rs("PlayType2")
		PlayUrl2=Rs("PlayUrl2")
		Content=Rs("Content")
		PostTime=Rs("PostTime")
		If Content="" Then Content="暂无简介！"
		If InStr(VideoPic,"http")>0 Then
			VideoPic=VideoPic
		Else
			VideoPic="/film/"&VideoPic
		End If
		If VideoState="" Or IsNull(VideoState) Then 
			VideoState=""
		Else
			VideoState="("&VideoState&")"
		End If
		'/获取该分类相关视频
		Dim ComVideo,HitsVideo
		ComVideo=GetTopVideo(HtmlTjNum,"And A.ClassID="&ClassID&"",3,False,False,True,20,2)
		HitsVideo=GetTopVideo(HtmlHitNum,"And A.ClassID="&ClassID&"",2,False,False,True,20,2)
		'/*获取播放地址列表
		Dim PlayList
		PlayList=GetPlayLinkList(ClassID,ClassEName,VideoID,VideoName,VideoEName,PlayType,PlayUrl,"1")
		PlayList=PlayList&GetPlayLinkList(ClassID,ClassEName,VideoID,VideoName,VideoEName,PlayType2,PlayUrl2,"2")
		'/获取导航
		Dim NavStr
		NavStr=">><a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&""">"&ClassName&"</a>>><a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&""">"&VideoName&"</a>"
		'/读取模版
		OutCode=Application("TempShowCode")
		'/替换模版
		OutCode=Replace(OutCode,"{Dm_WebName}",WebName)
		OutCode=Replace(OutCode,"{Dm_PageTitle}",VideoName&VideoState&"-"&VideoEName&"")
		OutCode=Replace(OutCode,"{Dm_Meta}",WebKey)
		OutCode=Replace(OutCode,"{Dm_Desc}",WebDes)
		OutCode=Replace(OutCode,"{Dm_WebUrl}",WebUrl)
		OutCode=Replace(OutCode,"{Dm_Channel}",GetChannelList(ClassID,2))
		OutCode=Replace(OutCode,"{Dm_NavBar}",NavStr)
		OutCode=Replace(OutCode,"{Dm_VideoID}",VideoID)
		OutCode=Replace(OutCode,"{Dm_VideoPic}",VideoPic)
		OutCode=Replace(OutCode,"{Dm_VideoName}",VideoName)
		OutCode=Replace(OutCode,"{Dm_VideoState}",VideoState)
		OutCode=Replace(OutCode,"{Dm_VideoEName}",VideoEName)
		OutCode=Replace(OutCode,"{Dm_Player}",Player)
		OutCode=Replace(OutCode,"{Dm_ClassName}",ClassName)
		OutCode=Replace(OutCode,"{Dm_Hits}","<script language='javascript' src='/film/Js/Hits.asp?ID="&VideoID&"'></script>")
		OutCode=Replace(OutCode,"{Dm_Content}",Content)
		OutCode=Replace(OutCode,"{Dm_PlayList}",PlayList)
		OutCode=Replace(OutCode,"{Dm_ComVideo}",ComVideo)
		OutCode=Replace(OutCode,"{Dm_HitsVideo}",HitsVideo)
		OutCode=Replace(OutCode,"{Dm_CopyRight}",WebCopy)
		'/生成内容页Html
		HtmlPageName="Index.html"
		HtmlSaveDir="/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)
		Set Fso=New DmFso
		If Fso.CheckFolder(HtmlSaveDir)=False Then
			Call Fso.CreateFolder(HtmlSaveDir)
		End If
		Call Fso.CreateFile(HtmlSaveDir&HtmlPageName,OutCode,True)
		Set Fso=Nothing
		'/*-----------生成播放页-----------*/
		Call MakePlayListLink(ClassID,ClassName,ClassEName,VideoID,VideoName,VideoEName,PlayType,PlayUrl,"1",ComVideo,HitsVideo)
		Call MakePlayListLink(ClassID,ClassName,ClassEName,VideoID,VideoName,VideoEName,PlayType2,PlayUrl2,"2",ComVideo,HitsVideo)
		'/*输出结果*/
		'Rf ("<li><a href="&HtmlSaveDir&HtmlPageName&" target='_blank'>"&HtmlSaveDir&HtmlPageName&"生成完毕！</a></li>")&vbcrlf
	End If
	Rs.Close
	Set Rs=Nothing
	Call DBUpDate("Dm_Video","IsHtml=1","VideoID="&VideoID&"")
End Function

Function GetPlayLinkList(ClassID,ClassEName,VideoID,VideoName,VideoEName,PlayType,PlayUrl,PlaySer)
	If PlayType<>"no" Then
		Dim TempStr
		TempStr=""
		TempStr=TempStr&"<h2>在线观看"&VideoName&"<span>(来源:"&PlayType&")</span></h2>"&vbcrlf
		TempStr=TempStr&"<div class=""vpl"">"&vbcrlf
		Dim Key,I,KeyEnd
		Key=Split(PlayUrl,Chr(13))
		If Key(Ubound(Key))="" Or Len(Key(Ubound(Key)))<=1 Then 
			KeyEnd=Ubound(Key)-1
		Else
			KeyEnd=Ubound(Key)
		End If
		For I = 0 To KeyEnd
			If InStr(Key(I),"$")>0 Then
				TempStr=TempStr&"<a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&PlaySer&"_"&I+1&".html"" target=""_blank"" title="""&VideoName&SplitStr(Key(I),"$",1)&""">"&SplitStr(Key(I),"$",1)&"</a>"
			Else
				If I=0 And KeyEnd=0 Then
					TempStr=TempStr&"<a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&PlaySer&"_"&I+1&".html"" target=""_blank"" title="""&VideoName&"全集"&""">全集</a>"
				Else
					TempStr=TempStr&"<a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&PlaySer&"_"&I+1&".html"" target=""_blank"" title="""&VideoName&"第"&I+1&"集"&""">第"&I+1&"集</a>"
				End If
			End If
		Next
		TempStr=TempStr&"</div>"&vbcrlf
		GetPlayLinkList=TempStr
	Else
		GetPlayLinkList=""
	End If
End Function
'/*生成内容播放页函数*/
Function MakePlayListLink(ClassID,ClassName,ClassEName,VideoID,VideoName,VideoEName,PlayType,PlayUrl,PlaySer,ComVideo,HitsVideo)
	If PlayType<>"no" Then
		Dim Key,I,KeyEnd
		Key=Split(PlayUrl,Chr(13))
		If Key(Ubound(Key))="" Or Len(Key(Ubound(Key)))<=1 Then 
			KeyEnd=Ubound(Key)-1
		Else
			KeyEnd=Ubound(Key)
		End If
		For I = 0 To KeyEnd
			'获取集数
			Dim PlayName
			If InStr(Key(I),"$")>0 Then
				PlayName=SplitStr(Key(I),"$",1)
				vPlayUrl=SplitStr(Key(I),"$",2)
			Else
				If I=0 And KeyEnd=0 Then
					PlayName="全集"
				Else
					PlayName="第"&I+1&"集"
				End If
				vPlayUrl=Key(I)
			End If
			'/获取导航
			Dim PlayNav
			PlayNav=">><a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&""">"&ClassName&"</a>>><a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&""">"&VideoName&"</a>>><a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&PlaySer&"_"&I+1&".html"">"&PlayName&"</a>"
			'/*获取FlashUrl*/
			Dim FlashUrl,SetUpMsg
			SetUpMsg="小贴示：如果无法播放,请点这里<a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW' target='_blank'>升级FLASH播放插件</a>才能观看。 "
			FlashUrl=""
			Select Case PlayType
				Case "youku"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/youku.js""></script>"
				Case "56"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/56.js""></script>"
				Case "sina"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/sina.js""></script>"
				Case "tudou"
					FlashUrl=FlashUrl&"<iframe marginwidth=0 marginheight=0  hspace=0 vspace=0 frameborder=0 scrolling=no src=/film/Js/tudou.htm?"&SplitStr(Key(I),"$",2)&" width=500 height=450></iframe>"
				Case "ouou"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/ouou.js""></script>"
				Case "6rooms"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/6rooms.js""></script>"
				Case "bobo"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/bobo.js""></script>"
					SetUpMsg="小贴示：如果无法播放,请点这里<a href='http://www.17bobo.com/Software/BoBo_ActiveX_V3_Pro_All.exe' target='_blank'>安装BOBOP2P插件</a>才能观看!"
				Case "qvod"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/qvod.js""></script>"
					SetUpMsg="小贴示：如果无法播放,请点这里<a href='http://update.qvod.com/QvodSetup.exe' target='_blank'>安装QVODP2P插件</a>才能观看!"
				Case "neo"
					FlashUrl=FlashUrl&"<script language=""javascript"">url ="""&vPlayUrl&""";</script>"&vbcrlf
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/neo.js""></script>"&vbcrlf
					SetUpMsg="小贴示：如果无法播放,请点这里<a href='http://www.nibaa.tv/download/download.jsp' target='_blank'>安装泥巴P2P插件</a>才能观看!"
				Case "xunlei"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""http://play.kankan.xunlei.com/u/KKPlayer/KKPlayer.js""></script>"&vbcrlf
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/xunlei.js""></script>"&vbcrlf
				Case "xunlei2"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/xunlei2.js""></script>"&vbcrlf
				Case "flv"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/flv.js""></script>"
				Case "real"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/real.js""></script>"
					SetUpMsg="小贴示：如果无法播放,请点这里<a href='http://www.skycn.com/soft/1760.html' target='_blank'>安装Realplayer</a>才能观看!"
				Case "media"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/media.js""></script>"
					SetUpMsg="小贴示：您只有<a href='http://www.skycn.com/soft/20492.html' target='_blank'>安装Windows Media Player</a>才能观看!双击电影可以全屏观看，再次双击可以退出！"
				Case "swf"
					FlashUrl=FlashUrl&"<script language=""javascript"" src=""/film/Js/swf.js""></script>"
			End Select
			If PlayType="tudou" Then
				FlashUrl=FlashUrl
			ElseIf PlayType="neo" Then
				FlashUrl=FlashUrl&"<div id=""playerctrl""></div>"&vbcrlf
				FlashUrl=FlashUrl&"<script language=javascript>"&vbcrlf
				FlashUrl=FlashUrl&"g_player.mediatype=url.substring(url.lastIndexOf(""."")+1);"&vbcrlf
				FlashUrl=FlashUrl&"g_player.pl_width=500;"&vbcrlf
				FlashUrl=FlashUrl&"g_player.pl_height=450;"&vbcrlf
				FlashUrl=FlashUrl&"g_player.load();"&vbcrlf
				FlashUrl=FlashUrl&"if(g_player.installed)"&vbcrlf
				FlashUrl=FlashUrl&"{"&vbcrlf
				FlashUrl=FlashUrl&"g_player.play(url);"&vbcrlf
				FlashUrl=FlashUrl&"}"&vbcrlf
				FlashUrl=FlashUrl&"</script>"&vbcrlf
			ElseIf PlayType="real" Then
				FlashUrl=FlashUrl&"<script language=""javascript"">addFlash('"&vPlayUrl&"','500','410');</script>"
			Else
				FlashUrl=FlashUrl&"<script language=""javascript"">addFlash('"&vPlayUrl&"','500','450');</script>"
			End If
			'获取改页面URL
			Dim PageUrl
			PageUrl=WebUrl&"/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&PlaySer&"_"&I+1&".html"
			'/读取模版
			OutCode=Application("TempPlayCode")
			'/替换模版
			OutCode=Replace(OutCode,"{Dm_WebName}",WebName)
			OutCode=Replace(OutCode,"{Dm_PageTitle}",VideoName&"-"&PlayName&"-"&VideoEName&"")
			OutCode=Replace(OutCode,"{Dm_Meta}",WebKey)
			OutCode=Replace(OutCode,"{Dm_Desc}",WebDes)
			OutCode=Replace(OutCode,"{Dm_WebUrl}",WebUrl)
			OutCode=Replace(OutCode,"{Dm_Channel}",GetChannelList(ClassID,2))
			OutCode=Replace(OutCode,"{Dm_NavBar}",PlayNav)
			OutCode=Replace(OutCode,"{Dm_VideoID}",VideoID)
			OutCode=Replace(OutCode,"{Dm_PlayName}",PlayName)
			OutCode=Replace(OutCode,"{Dm_FlashUrl}",FlashUrl)
			OutCode=Replace(OutCode,"{Dm_PlayList}",GetPlayPageLinkList(ClassID,ClassEName,VideoID,VideoName,VideoEName,PlayType,PlayUrl,PlaySer,I))
			OutCode=Replace(OutCode,"{Dm_PlayType}",PlayType)
			OutCode=Replace(OutCode,"{Dm_PageUrl}",PageUrl)
			OutCode=Replace(OutCode,"{Dm_VideoName}",VideoName)
			OutCode=Replace(OutCode,"{Dm_VideoEName}",VideoEName)
			OutCode=Replace(OutCode,"{Dm_ClassName}",ClassName)
			OutCode=Replace(OutCode,"{Dm_SetUp}",SetUpMsg)
			OutCode=Replace(OutCode,"{Dm_Hits}","<script language='javascript' src='/film/Js/Hits.asp?ID="&VideoID&"'></script>")
			OutCode=Replace(OutCode,"{Dm_ComVideo}",ComVideo)
			OutCode=Replace(OutCode,"{Dm_HitsVideo}",HitsVideo)
			OutCode=Replace(OutCode,"{Dm_CopyRight}",WebCopy)
			If PlayType="neo" Then
				OutCode=Replace(OutCode,"<div id=""flashdiv"" style=""display:none;"">","<div id=""flashdiv"">")
				OutCode=Replace(OutCode,"<span id=""loadimg""><iframe src=""/film/Js/loading.html"" frameborder=""0"" scrolling=""no"" width=""500"" height=""450""></iframe></span>","")
				OutCode=Replace(OutCode,"<script language=""javascript"" src=""/film/Js/settime.js""></script>","")
			End If
			'/生成内容页Html
			HtmlPageName=PlaySer&"_"&I+1&".html"
			HtmlSaveDir="../../film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)
			Set Fso=New DmFso
			If Fso.CheckFolder(HtmlSaveDir)=False Then
				Call Fso.CreateFolder(HtmlSaveDir)
			End If
			Call Fso.CreateFile(HtmlSaveDir&HtmlPageName,OutCode,True)
			Set Fso=Nothing
			'Rf ("<li><a href="&HtmlSaveDir&HtmlPageName&" target='_blank'>"&HtmlSaveDir&HtmlPageName&"生成完毕！</a></li>")&vbcrlf
			If I<KeyEnd Then
				Rf "<script>loadtc.innerHTML=""视频ID <font color='red'>"&VideoID&"</font> 播放服务器"&PlayType&" 共有播放页"&KeyEnd&"页  正在生成第<font color='red'>"&I&"</font>页 "";</script>"
			End If
		Next
	End If
End Function
Function GetPlayPageLinkList(ClassID,ClassEName,VideoID,VideoName,VideoEName,PlayType,PlayUrl,PlaySer,NowID)
	Dim Key,I,KeyEnd
	Key=Split(PlayUrl,Chr(13))
	If Key(Ubound(Key))="" Or Len(Key(Ubound(Key)))<=1 Then 
		KeyEnd=Ubound(Key)-1
	Else
		KeyEnd=Ubound(Key)
	End If
	PlayPageList=""
	For I = 0 To KeyEnd
		If InStr(Key(I),"$")>0 Then
			PlayPageList=PlayPageList&"<a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&PlaySer&"_"&I+1&".html"" title="""&VideoName&SplitStr(Key(I),"$",1)&""""
		Else
			If I=0 And KeyEnd=0 Then
				PlayPageList=PlayPageList&"<a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&PlaySer&"_"&I+1&".html"" title="""&VideoName&"全集"""
			Else
				PlayPageList=PlayPageList&"<a href=""/film/film/"&GetClassPath(ClassID,ClassEName)&GetVideoPath(VideoID,VideoEName)&PlaySer&"_"&I+1&".html"" title="""&VideoName&"第"&I+1&"集"""
			End If
		End If
		If I=NowID Then PlayPageList=PlayPageList&"class=""now"" "
		If InStr(Key(I),"$")>0 Then
			PlayPageList=PlayPageList&">"&SplitStr(Key(I),"$",1)&"</a>"
		Else
			If I=0 And KeyEnd=0 Then
				PlayPageList=PlayPageList&">全集</a>"
			Else
				PlayPageList=PlayPageList&">第"&I+1&"集</a>"
			End If
		End If
	Next
	GetPlayPageLinkList=PlayPageList
End Function


Function LoadingBar(Url)
	Rf "<div id=""loadbar"">" &vbCrLf
	Rf "<div id=""loadtd""><div id=""loadtb""></div></div>" &vbCrLf
	Rf "<div id=""loadtxt""></div>" &vbCrLf
	Rf "<div id=""loadbove""><input name=""Back"" id=""backb"" type=""button"" onclick=""location.href='"&Url&"';"" value="" 返 回 ""/></div>" &vbCrLf
	Rf "<div id=""loadtc""></div>"
	Rf "</div>"&vbCrLf
End Function
%>
<% Call CloseDB() %>
</body>
</html>