<%
Function GetRndPassword(PasswordLen)'生成随机
    Dim Ran, i, strPassword
    strPassword = ""
    For i = 1 To PasswordLen
        Randomize
        Ran = CInt(Rnd * 2)
        Randomize
        If Ran = 0 Then
            Ran = CInt(Rnd * 25) + 97
            strPassword = strPassword & UCase(Chr(Ran))
        ElseIf Ran = 1 Then
            Ran = CInt(Rnd * 9)
            strPassword = strPassword & Ran
        ElseIf Ran = 2 Then
            Ran = CInt(Rnd * 25) + 97
            strPassword = strPassword & Chr(Ran)
        End If
    Next
    GetRndPassword = strPassword
End Function

Function QvodCms_Radio(str1,str2)'判断显示radio
    If str1=str2 Then Response.Write"checked"
End Function

Function QvodCms_Select(str1,str2)'判断显示Select
    If str1=str2 Then
	QvodCms_Select="selected"
	Else
	QvodCms_Select=""
	End If
End Function

Function GetAdName(strid)'读出广告文件名
    Set rs=Conn.Execute("select ad_id from qvodcms_ad where ad_id="&strid&"")
	If Not rs.eof Then
		GetAdName=Trim(rs("ad_id"))
	Else
	    GetAdName="no"
	End If		
	Set rs=nothing
End Function

Function GetCountHttp'统计远程图片
    Set rs = Conn.Execute("select Count(name_id) as pic from qvodcms_name where data_status=1 and Left(data_picbig,7)='http://'" )
	Session("httpimg") = rs("pic")
	rs.close
	Set rs=nothing
	GetCountHttp = Session("httpimg")
End Function

'作用：判断当前影片是否热门
Sub DataHits(data_hits)
    If Clng(data_hits)>=Clng(AdminId(28)) Then 
	Response.Write("checked")
	AdminId(28)=data_hits
	End If
End Sub

Sub GetEreaName(strid)'作用：读出地区
    dim bid,eid,j
	bid=split(AdminId(0),",")
	eid=ubound(bid)
	For j=0 to eid
	If bid(j)=strid Then
	Response.Write"<option value="""&bid(j)&""" selected>"&bid(j)&"</option>"
	Else
    Response.Write"<option value="""&bid(j)&""">"&bid(j)&"</option>"
	End If
	Next
End Sub

Sub GetYearName(strid)'作用：读出年份
    dim bid,eid,j
	bid=split(AdminId(2),",")
	eid=ubound(bid)
	For j=0 to eid
	If cint(bid(j))=strid Then
	Response.Write"<option value="""&bid(j)&""" selected>"&bid(j)&"</option>"
	Else
    Response.Write"<option value="""&bid(j)&""">"&bid(j)&"</option>"
	End If
	Next
End Sub

Sub Language'作用：读出语言
    dim bid,eid,j
	bid=split(AdminId(1),",")
	eid=ubound(bid)
	For j=0 to eid
    Response.Write"<a href='#' onClick=data_language.value='"&bid(j)&"'>"&bid(j)&"</a> "
	Next
End Sub

Sub GetDataColor(data_color)'作用：颜色
%>
<option value=''>颜色</option>                      
<option value=''>默认</option>                      
<option value='#000000' style='background-color:#000000' <%If data_color="#000000" Then Response.Write "selected"%>></option>
<option value='#FFFFFF' style='background-color:#FFFFFF' <%If data_color="#FFFFFF" Then Response.Write "selected"%>></option>
<option value='#008000' style='background-color:#008000' <%If data_color="#008000" Then Response.Write "selected"%>></option>
<option value='#FFFF00' style='background-color:#FFFF00' <%If data_color="#FFFF00" Then Response.Write "selected"%>></option>
<option value='#FF0000' style='background-color:#FF0000' <%If data_color="#FF0000" Then Response.Write "selected"%>></option>
<option value='#0000FF' style='background-color:#0000FF' <%If data_color="#0000FF" Then Response.Write "selected"%>></option>                      
<%End Sub
'**************************************************
'TypeID：大类ID
'作  用：显示无级分类
'Call QvodCms_Class_Name(0,"",classid)
'**************************************************
Function QvodCms_Class_Name(TypeID,CompatStr,ID)'递归查询分类
		Dim RSclass,TempStr
		Set RSclass = Conn.Execute("select class_id,class_name,class_dir,class_orderid,class_bigid from qvodcms_class where class_bigid="&TypeID&" and class_orderid>0 order by class_orderid asc" )
		TempStr =CompatStr & "┄"
		Do While Not RSclass.Eof
		if RSclass("class_id")=ID then
			QvodCms_Class_Name = QvodCms_Class_Name & "<option value="""& RSclass("class_id") &""" selected>"
		else
			QvodCms_Class_Name = QvodCms_Class_Name & "<option value="""& RSclass("class_id") &""">"
		end if
			QvodCms_Class_Name = QvodCms_Class_Name & "├" & TempStr &  RSclass("class_name")
			QvodCms_Class_Name = QvodCms_Class_Name & "</option>" & Chr(13) & Chr(10)
			QvodCms_Class_Name = QvodCms_Class_Name &QvodCms_Class_Name(RSclass("class_id"),TempStr,ID)
		RSclass.MoveNext
		loop
		RSclass.Close
		Set RSclass = Nothing
End Function

'**************************************************
'TypeID：大类ID
'作  用：显示无级分类
'Call QvodCms_Class_News(0,"",classid)
'**************************************************
Function QvodCms_Class_News(TypeID,CompatStr,ID)'递归查询分类
		Dim RSclass,TempStr
		Set RSclass = Conn.Execute("select news_class_id,class_name,class_dir,class_orderid,class_bigid from qvodcms_news_class where class_bigid="&TypeID&" and class_orderid>0 order by class_orderid asc" )
		TempStr =CompatStr & "┄"
		Do While Not RSclass.Eof
		if RSclass("news_class_id")=ID then
			QvodCms_Class_News = QvodCms_Class_News & "<option value="""& RSclass("news_class_id") &""" selected>"
		else
			QvodCms_Class_News = QvodCms_Class_News & "<option value="""& RSclass("news_class_id") &""">"
		end if
			QvodCms_Class_News = QvodCms_Class_News & "├" & TempStr &  RSclass("class_name")
			QvodCms_Class_News = QvodCms_Class_News & "</option>" & Chr(13) & Chr(10)
			QvodCms_Class_News = QvodCms_Class_News &QvodCms_Class_News(RSclass("news_class_id"),TempStr,ID)
		RSclass.MoveNext
		loop
		RSclass.Close
		Set RSclass = Nothing
End Function

Function QvodCms_Elite(data_id,elite_id)'推荐影片
    If elite_id<>1 then elite_id=0 
	Conn.Execute(" Update [qvodcms_name] Set data_elite="&elite_id&" Where data_id="&data_id&" ")
End Function

Function QvodCms_Status(data_id,elite_id)'审核影片
    If elite_id<>1 then elite_id=0 
	Conn.Execute(" Update [qvodcms_name] Set data_status="&elite_id&" Where data_id="&data_id&" ")
End Function

Function qvodcmstop(classid,act)'排行榜生成
Strhtml="<table width='100%' border='0' cellspacing='0' cellpadding='0' class='topli'>"
if act=0 then
Set rs=Conn.Execute("select name_id,class_id,data_name,data_hits,data_py from qvodcms_name where class_id="&classid&" order by data_hits desc")
elseif Config(1)="SQL" Then
Set rs=Conn.Execute("select name_id,class_id,data_name,data_hits,data_py from qvodcms_name where datediff(d,data_lastdate,getdate())<"&act&" and class_id="&classid&" order by data_hits desc")
else
Set rs=Conn.Execute("select name_id,class_id,data_name,data_hits,data_py from qvodcms_name where datediff('d',data_lastdate,now())<"&act&" and class_id="&classid&" order by data_hits desc")
End If
If Not(rs.bof And rs.eof) Then
i=0
Do while not rs.eof
i=i+1
if i<10 then
 ii="0"&i
Else
 ii=i
End if 
Strhtml=Strhtml&"<tr><td width='75%' height='22' class='topnb'><span class='nbi'>"&ii&"</span> <a href='"&GetDataLink(rs("class_id"),rs("name_id"),rs("data_py"))&"' target='_blank' title='"&rs("data_name")&"'>"&GetSubStr(Trim(rs("data_name")),23,True)&"</a></td><td class='tophits'>"&rs("data_hits")&"</td></tr>"
if i=10 then exit do
rs.movenext:loop
Else
Strhtml=Strhtml&"<tr><td height='22' colspan='2'>该分类没有数据!</td></tr>"
End If
Set rs=nothing
Strhtml=Strhtml&"<tr></tr></table>"
qvodcmstop=Strhtml
End Function

Function QvodCms_PlayUrl(server_id,data_id)'获取具体播放地址
    Set Ru = Conn.Execute("select top 1 * from QvodCmsim_url where server_id="&server_id&" and data_id="&data_id&"" )
	If Not(Ru.bof and Ru.eof) Then
	QvodCms_PlayUrl=Trim(Replace(Ru("url_intro"),"$$$",chr(13)))
	Else
	QvodCms_PlayUrl=""
	End If
	Set Ru = nothing
End Function

Function htmltojs(content)
    arrLines = Split(content, Chr(10) )
    If IsArray(arrLines) then
    For i=0 To UBound( arrLines )
	sLine = Replace( arrLines(i) , "\" , "\\")
	sLine = Replace( sLine , "/" , "\/")
	sLine = Replace( sLine , "'" , "\'")
	sLine = Replace( sLine , """" , "\""")
    sLine = Replace( sLine , Chr(13) , "" )
    strNew = strNew & "document.writeln('" & sLine  & "');" & Chr(10)
    Next
    End If
    htmltojs=strNew
End Function

Function jstohtml(content)
	content = Replace( content , "document.writeln('" , "")
	content = Replace( content , "\'" , "'")
	content = Replace( content , "\""" , """")
	content = Replace( content , "\\" , "\")
	content = Replace( content , "\/" , "/")
	content = Replace( content , "');" , "")
    jstohtml=content
End Function

Function PlaySelect(Str)'作用:处理循环影片的服务器组
    Dim Sel,PlayStr:PlayStr=""
    for i=1 to From_Count
	   If Trim(Str)=Trim(playfrom(i)) Then Sel="selected" Else Sel=""
	   PlayStr=PlayStr&"<option value='"&Trim(playfrom(i))&"' "&Sel&">"&Trim(playfrom(i))&"__"&playUrl(i)&"</option>"
    next	
	'PlayStr="<option value='快播QVOD'>快播QVOD__qvod.com</option><option value='迅播GVOD'>迅播GVOD__gvod.xunlei.com</option><option value='闪播Pvod'>闪播Pvod__pvod.cn</option><option value='优酷视频'>优酷视频__youku.com</option><option value='土豆高清'>土豆高清(黑豆)__tudou.com</option><option value='56视频'>56视频__tv.56.com</option><option value='ku6视频'>ku6视频(高清)__hd.ku6.com</option><option value='FLV视频'>FLV视频__Flv文件地址</option><option value='SWF数据'>SWF数据__Swf文件地址</option><option value='Media'>Media__Wmv,Asf等格式</option>"
	PlaySelect=PlayStr
End Function

Function transferUrl(Byval fromStr,Byval playStr)
	Dim fromLen,playLen,fromArray,playArray,i,resultStr
	IF IsNul(fromStr) and IsNul(playStr) Then transferUrl="" : Exit Function
	fromStr=replaceStr(fromStr,"$$","") : playStr=replaceStr(replaceStr(playStr,"#",""),"$$","")
	playStr=replaceStr(playStr,chr(10),"")
	playStr=replaceStr(playStr,chr(13),"#")
	playStr=trimOuterStr(playStr,"#")
	fromStr=trimOuterStr(fromStr,",") : playStr=trimOuterStr(playStr,",") 
	fromArray=split(fromStr,", ") : fromLen=ubound(fromArray)
	playArray=split(playStr,", ") : playLen=ubound(playArray)
	IF fromLen<>playLen Then Call QvodCms_Err("出错了，来源或地址没有填写完整！")
	For i=0 To fromLen
		IF fromArray(i)="" or playArray(i)="" Then
			Call QvodCms_Err("出错了，来源或地址没有填写完整！")
			Exit For
		End iF
	Next
	playStr=ReplaceStr(playStr,", ","$$$")
	IF Not IsNul(playStr) Then
	i=0
	Arr1=Split(playStr,"$$$")
	For i=0 To Ubound(Arr1)
		IF Not IsNul(Arr1(i)) Then 
			Arr2=Split(Arr1(i),"#")
			For j=0 To Ubound(Arr2)
				IF Not IsNul(Arr2(j)) Then Strs=Strs&Arr2(j)&"#"
			Next
			Strs=trimOuterStr(Strs,"#")
		End IF
		Strs=Strs&"$$$"
	Next
	End IF
	transferUrl=trimOuterStr(Strs,"$$$")
End Function

Function trimOuterStr(Byval str,Byval flag)
	Dim vstr,m : vstr = str : m=len(flag)
	IF left(vstr,m) = flag Then vstr = right(vstr,len(vstr)-m) 
	IF right(vstr,m) = flag Then  vstr = left(vstr,len(vstr)-m)
	trimOuterStr = vstr
End Function
%>