
<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<%
response.Charset="GBK"
Function getArticleLink(ByVal articleId)
	dim linkStr
	if app_viewtype=0 then
		linkStr= app_installdir&"article/?"&articleId& "." &app_htmlSuffix
	else
		linkStr= app_installdir&app_articlepath&"/"&app_articlename&articleId&"."&app_htmlSuffix
	end if
	getArticleLink = linkStr
end function

Function getIndexLink()
	if app_viewtype=1 then
		getIndexLink= app_installdir&"index.asp"
	else 
		getIndexLink= app_installdir&"index."&app_htmlSuffix
	end if
End Function

Function getTopicIndexLink()
	if app_viewtype=1 then
		getTopicIndexLink= app_installdir&app_topicpath&"/index.asp"
	else 
		getTopicIndexLink= app_installdir&app_topicpath&"/index."&app_htmlSuffix
	end if
End Function

Function getTypeLink(Byval typeId)
	dim linkStr,typePath
	if app_viewtype="0" then  
		linkStr= app_installdir&"list/?"&typeId& "." &app_htmlSuffix
	elseif app_viewtype="1"  then
		linkStr= app_installdir&app_listpath&"/"&app_listname&typeId&"."&app_htmlSuffix
	elseif app_viewtype="2"  then
		typePath = CacheOBJ.loadTypePathOnCache(typeId)
		linkStr= app_installdir&typePath&"/index."&app_htmlSuffix
	end if
	getTypeLink=linkStr
End Function

Function getViewLink(Byval typeId,Byval videoId)
	dim linkStr,typePath
	if app_viewtype=0 then  
		linkStr= app_installdir&"view/?"&videoId& "." & app_htmlSuffix
	elseif app_viewtype=1  then
		linkStr= app_installdir&app_viewpath & "/" & app_viewname & "_" & videoId & "." &app_htmlSuffix
	elseif app_viewtype=2 then
		typePath = CacheOBJ.loadTypePathOnCache(typeId)
		linkStr=  app_installdir&typePath&"/"&videoId&"/index."&app_htmlSuffix
	end if
	getViewLink=linkStr
End Function

Function getPlayLink(Byval typeId,Byval videoId)
	dim linkStr,typePath
	if app_makeplay=0 then getPlayLink=app_installdir&"play/?"&videoId:Exit Function
	
	if app_viewtype=0 then  
		linkStr= app_installdir&"play/?"&videoId& "." & app_htmlSuffix
	elseif app_viewtype=1  then
		linkStr= app_installdir&app_playpath&"/"&app_playname&videoId& "." &app_htmlSuffix
	elseif app_viewtype=2 then
		typePath = CacheOBJ.loadTypePathOnCache(typeId)
		linkStr= app_installdir&typePath&"/"&videoId&"/"&app_playname& "." &app_htmlSuffix
	end if
	getPlayLink=linkStr
End Function

Function  getPlayUrlList(Byval src,Byval url,Byval videoId)
	dim urlArray,singleUrlArray,urlCount,i,urlStr,contactStr,behindStr,num
	
	if isN(url) then
		getPlayUrlList="" : Exit Function
	else
		url=Replace(url,chr(10),"")
	 	url=Replace(url,chr(13),"#")
		url=Replace(url,"##","")
		urlArray=split(url,"#")
		urlCount=ubound(urlArray)
		
		urlStr="<h3>播放服务器["&src&"]号</h3><div class=""list""><ul>"
		for i=0 to urlCount
			if not isN(urlArray(i)) then
				singleUrlArray=split(urlArray(i),"$")
				num = ubound(singleUrlArray)
				if num > 0 then 
				if app_viewtype=0 or app_makeplay=0 then 
					urlStr=urlStr&"<li><a target='_blank' title='"&singleUrlArray(0)&"' href='"&app_installdir&"play/?"& videoId & "," & src & "," & i & "." &app_htmlSuffix&"'>"&singleUrlArray(0)&"</a></li>"
				elseif app_viewtype=1  then
					urlStr=urlStr&"<li><a target='_blank' title='"&singleUrlArray(0)&"' href='"&app_installdir&app_playpath& "/" & app_playname & "_" & videoId & "." & app_htmlSuffix&"?"&src&","&i&"'>"&singleUrlArray(0)&"</a></li>"
				elseif app_viewtype=2  then
					urlStr=urlStr&"<li><a target='_blank' title='"&singleUrlArray(0)&"' href='"&app_installdir&"play/?"& videoId & "," & src & "," & i & "." &app_htmlSuffix&"'>"&singleUrlArray(0)&"</a></li>"
				end if
				else
				if app_viewtype=0 or app_makeplay=0 then 
					urlStr=urlStr&"<li><a target='_blank' title='第"&i+1&"集' href='"&app_installdir&"play/?"& videoId & "," & src & "," & i & "." &app_htmlSuffix&"'>第"&i+1&"集</a></li>"
				elseif app_viewtype=1  then
					urlStr=urlStr&"<li><a target='_blank' title='第"&i+1&"集' href='"&app_installdir&app_playpath& "/" & app_playname & "_" & videoId & "." & app_htmlSuffix&"?"&src&",第"&i+1&"集'>"&i&"</a></li>"
				elseif app_viewtype=2  then
					urlStr=urlStr&"<li><a target='_blank' title='第"&i+1&"集' href='"&app_installdir&"play/?"& videoId & "," & src & "," & i & "." &app_htmlSuffix&"'>第"&i+1&"集</a></li>"
				end if
				end if
			end if
		next
	end if
	getPlayUrlList = urlStr&"</ul></div>"
End Function


Function  getPlayerList(Byval src,Byval url,Byval videoId,Byval currentNum)
	dim urlArray,singleUrlArray,urlCount,i,urlStr,contactStr,behindStr,num
	
	if isN(url) then
		getPlayerList="" : Exit Function
	else
		url=Replace(url,chr(10),"")
	 	url=Replace(url,chr(13),"#")
		url=Replace(url,"##","")
		urlArray=split(url,"#")
		urlCount=ubound(urlArray)
		
		
		urlStr="<ul>"
		for i=0 to urlCount
			if not isN(urlArray(i)) then
				singleUrlArray=split(urlArray(i),"$")
				num = ubound(singleUrlArray)
				if i = clng(currentNum) then
					
					if num > 0 then 
						urlStr=urlStr&"<li><span class=""playerlist redcolor"">"&singleUrlArray(0)&"</span></li>"
					else
						urlStr=urlStr&"<li><span class=""playerlist redcolor"">第"&i+1&"集</span></li>"
					end if
				
				else

				if num > 0 then 
				if app_viewtype=0 or app_makeplay=0 then 
					urlStr=urlStr&"<li><a target='_blank' title='"&singleUrlArray(0)&"' href='"&app_installdir&"play/?"& videoId & "," & src & "," & i & "." &app_htmlSuffix&"'>"&singleUrlArray(0)&"</a></li>"
				elseif app_viewtype=1  then
					urlStr=urlStr&"<li><a target='_blank' title='"&singleUrlArray(0)&"' href='"&app_installdir&app_playpath& "/" & app_playname & "_" & videoId & "." & app_htmlSuffix&"?"&src&","&i&"'>"&singleUrlArray(0)&"</a></li>"
				elseif app_viewtype=2  then
					urlStr=urlStr&"<li><a target='_blank' title='"&singleUrlArray(0)&"' href='"&app_installdir&"play/?"& videoId & "," & src & "," & i & "." &app_htmlSuffix&"'>"&singleUrlArray(0)&"</a></li>"
				end if
				else
				if app_viewtype=0 or app_makeplay=0 then 
					urlStr=urlStr&"<li><a target='_blank' title='第"&i+1&"集' href='"&app_installdir&"play/?"& videoId & "," & src & "," & i & "." &app_htmlSuffix&"'>第"&i+1&"集</a></li>"
				elseif app_viewtype=1  then
					urlStr=urlStr&"<li><a target='_blank' title='第"&i+1&"集' href='"&app_installdir&app_playpath& "/" & app_playname & "_" & videoId & "." & app_htmlSuffix&"?"&src&",第"&i+1&"集'>"&i&"</a></li>"
				elseif app_viewtype=2  then
					urlStr=urlStr&"<li><a target='_blank' title='第"&i+1&"集' href='"&app_installdir&"play/?"& videoId & "," & src & "," & i & "." &app_htmlSuffix&"'>第"&i+1&"集</a></li>"
				end if
				end if
				end if
			end if
		next
	end if
	getPlayerList = urlStr&"</ul>"
End Function


Function makePageNumber(Byval currentPage,Byval pageListLen,Byval totalPages,Byval linkType)
	dim beforePages,pagenumber,page
	dim beginPage,endPage,strPageNumber
	if pageListLen mod 2 = 0 then beforePages = pagelistLen / 2 else beforePages = clng(pagelistLen / 2) - 1
	if  currentPage < 1  then currentPage = 1 else if currentPage > totalPages then currentPage = totalPages
	if pageListLen > totalPages then pageListLen=totalPages
	if currentPage - beforePages < 1 then
		beginPage = 1 : endPage = pageListLen
	elseif currentPage - beforePages + pageListLen > totalPages  then
		beginPage = totalPages - pageListLen + 1 : endPage = totalPages
	else 
		beginPage = currentPage - beforePages : endPage = currentPage - beforePages + pageListLen - 1
	end if	
	for pagenumber = beginPage  to  endPage
		if pagenumber=1 then page = "" else page = pagenumber
		if pagenumber=currentPage then
			if linkType="searchlist" or linkType="typelist" then 
				strPageNumber=strPageNumber&"<em>"&pagenumber&"</em>"
			else
				strPageNumber=strPageNumber&"<span><font color=red>"&pagenumber&"</font></span>"&"&nbsp;"
			end if
		else
			select case linkType
				case "typelist" 
					strPageNumber=strPageNumber&"<a href='"&getChannelPagesLink(currentTypeId,pagenumber)&"'>"&pagenumber&"</a>"
				case "searchlist" 
					strPageNumber=strPageNumber&"<a href='?page="&pagenumber&"&keyword="&keyword&"'>"&pagenumber&"</a>"
				case "newslist"
					strPageNumber=strPageNumber&"<a href='?page="&pagenumber&"&where="&where&"&action="&action&"'>"&pagenumber&"</a>&nbsp;"
			end select
		end if	
	next
	makePageNumber=strPageNumber
End Function


Function pageNumberLinkInfo(Byval currentPage,Byval pageListLen,Byval totalPages,Byval linkType)
	dim pageNumber,pagesStr,i,pageNumberInfo,firstPageLink,lastPagelink,nextPagelink,finalPageLink,listi,selected
	pageNumber=makePageNumber(currentPage,pageListLen,totalPages,linkType)
	select case  linkType
		case "searchlist"
			if currentPage=1 then  
				firstPageLink="<em class='nolink'>首页</em>" : lastPagelink="<em class='nolink'>上一页</em>"
			else
				firstPageLink="<a  href='?page=1&keyword="&keyword&"'>首页</a>" : lastPagelink="<a  href='?page="&currentPage-1&"&keyword="&keyword&"'>上一页</a>"
			end if 
			if currentPage=totalPages then 
				nextPagelink="<em class='nolink'>下一页</em>" : finalPageLink="<em class='nolink'>尾页</em>"
			else
				nextPagelink="<a  href='?page="&currentPage+1&"&keyword="&keyword&"'>下一页</a>" : finalPageLink="<a  href='search.asp?page="&totalPages&"&keyword="&keyword&"'>尾页</a>"
			end if 
			
			pagesStr = "&nbsp;&nbsp;<select name=""select"" size=""1"" style=""font-size: 12px"" onchange=""javascript:window.location.href=this.options[this.selectedIndex].value"">"
			
			For listi=1 to totalPages
				selected=""
				IF cint(currentPage)=listi then 
				selected=" selected"
				end if
				
				pagesStr = pagesStr&"<option"&selected&" value="&app_installdir&"search.asp?page="&listi &"&keyword="&keyword&">第"&listi&"页</option>"
				
			Next
			pagesStr = pagesStr&"</select>"
			
			
			pageNumberInfo="<span>共"&totalPages&"页 页次:"&currentPage&"/"&totalPages&"页</span>"&firstPageLink&lastPagelink&pageNumber&""&nextPagelink&""&finalPagelink&pagesStr
		case "typelist"
			if currentPage=1 then  
				getChannelPagesLink currentTypeId,currentPage-1
				firstPageLink="<em class='nolink'>首页</em>" : lastPagelink="<em class='nolink'>上一页</em>"
			else
				firstPageLink="<a  href='"&getChannelPagesLink(currentTypeId,1)&"'>首页</a>" : lastPagelink="<a  href='"&getChannelPagesLink(currentTypeId,currentPage-1)&"'>上一页</a>"
			end if 
			if currentPage=totalPages then 
				nextPagelink="<em class='nolink'>下一页</em>" : finalPageLink="<em class='nolink'>尾页</em>"
			else
				nextPagelink="<a  href='"&getChannelPagesLink(currentTypeId,currentPage+1)&"'>下一页</a>" : finalPageLink="<a  href='"&getChannelPagesLink(currentTypeId,totalPages)&"'>尾页</a>"
			end if 
			pagesStr = "&nbsp;&nbsp;<select name=""select"" size=""1"" style=""font-size: 12px"" onchange=""javascript:window.location.href=this.options[this.selectedIndex].value"">"
			
			For listi=1 to totalPages
				selected=""
				IF cint(currentPage)=listi then 
				selected=" selected"
				end if
				if app_viewtype="0" then  
					pagesStr = pagesStr&"<option"&selected&" value="&app_installdir&"list/?"&currentTypeId& "-" &listi & "." &app_htmlSuffix &  ">第"&listi&"页</option>"
				end if
			Next
			pagesStr = pagesStr&"</select>"
			
			pageNumberInfo="<span>共"&totalPages&"页 页次:"&currentPage&"/"&totalPages&"页</span>"&firstPageLink&lastPagelink&pageNumber&""&nextPagelink&""&finalPagelink&pagesStr
	end select
	pageNumberLinkInfo=pageNumberInfo
End Function

Function getPageSize(Byval str,Byval ptype)
	dim regObj,matchChannel,matchesChannel,sizeValue
	set regObj = New RegExp
	regObj.Pattern = "\{Label:"&ptype&"list[\s\S]*num=([\d]+)[\s\S]*\}"	
	set matchesChannel = regObj.Execute(str)
	for each matchChannel in matchesChannel
		sizeValue = matchChannel.SubMatches(0) : if isN(sizeValue) then sizeValue=10
		set regObj = nothing
		set matchesChannel = nothing
		getPageSize = sizeValue
		Exit Function
	next
End Function

Function getChannelPagesLink(Byval typeId,Byval page)
	dim linkStr,typePath,tempStr
	
	if app_viewtype="0" then  
		if clng(page)=1 then tempStr=""  else tempStr="-"&page
		linkStr= app_installdir&"list/?"&typeId&tempStr&"." &app_htmlSuffix
		
	elseif app_viewtype="1"  then
		if clng(page)=1 then tempStr=""  else tempStr="_"&page
		linkStr= app_installdir&app_listpath&"/"&app_listname&typeId&tempStr&"."&app_htmlSuffix
	elseif app_viewtype="2"  then
		typePath = CacheOBJ.loadTypePathOnCache(typeId)
		if clng(page)=1 then page=""
		linkStr= app_installdir&typePath&"/index"&page&"."&app_htmlSuffix
	end if
	getChannelPagesLink=linkStr
End Function

Function getPlayInfo(Byval type1,Byval url1,Byval type2,Byval url2)
	Dim urlStr
	url1=Replace(url1,chr(10),"")
	url1=Replace(url1,chr(13),"#")
	url1=Replace(url1,"##","")
	
	url2=Replace(url2,chr(10),"")
	url2=Replace(url2,chr(13),"#")
	url2=Replace(url2,"##","")
	
	urlStr = "<script>var playtype1= '"&type1&"' ; var playlist1 = '" & url1 & "';</script>" & vbcrlf
	urlStr = urlStr & "<script>var playtype2= '"&type2&"' ; var playlist2 = '" & url2 & "';</script>" & vbcrlf
	urlStr = urlStr & "<script>var unionplayurl='"& GetUnionPlayUrl(type1) & "';</script>"
	getPlayInfo = urlStr
end Function

Function getKeywordsList(key,span)
	dim keyWordsArray,i,keyWordsStr
	keyWordsArray = split(replace(replace(key,"，",",")," ",","),",")
	for i=0 to ubound(keyWordsArray)
		keyWordsStr = keyWordsStr & "<a href='"&app_installdir&"search.asp?keyword="& keyWordsArray(i)&"'>"&keyWordsArray(i)&"</a>"&span
	next
	getKeywordsList = keyWordsStr
End Function

Function getPlayer()
	getPlayer = "<script> var paras=getHtmlParas('"&app_htmlSuffix&"'); viewplay(paras[1],paras[2]); </script>"
end Function

Function getColorName(Byval strname,Byval strcolor)
	if not isN(strcolor) then getColorName ="<font color='"&strcolor&"'>"&strname&"</font>"	else  getColorName= strname
end Function

Function getDataCountByDay()
	dim whereStr
	whereStr = " where year(D_AddTime)="&Year(date)&" and month(D_AddTime)="&month(date)&" and day(D_AddTime)="&day(date)
		getDataCountByDay = Database.GetRecordBySQL("select count(*) from Tbl_Datas" & whereStr)(0)
End Function

Function getDataCountAll()
		getDataCountAll = Database.GetRecordBySQL("select count(*) from Tbl_Datas")(0)
End Function

Function getDicName(table,tablesname,tablesid,id)
	 getDicName  = Database.ReadTable(table,tablesid &"="& id, tablesname)   
End Function

Function getDicCount(table,tablesid,id)
	 getDicCount = Database.GetRecordBySQL("select count(*) from "&table&" where "& tablesid &" = " &id)(0)

End Function

Function getData(data)
	if isN(data) then data = ""
	getData = data
end function


%>