<%
'===================================================
' CreateLive CMS Version 3.1
'							Powered by Aspoo.CoM
'===================================================
' File: Cl_Function_Photo.asp
' Date: 2005-10-31
' Mail: aspoo@126.com, Info@aspoo.cn
' Q  Q: 3315263, 596197794
' Msn : aspoo@126.com, Clw866@hotmail.com
' Web : http://www.aspoo.com, http://www.aspoo.net
' Bbs : http://bbs.aspoo.com, http://bbs.aspoo.net
' Copyright (C) 2005 Aspoo.CoM All Rights Reserved.
'===================================================
Public Sub Photo_Setting()
	CurrentPath = Cl.lanstr(1) & "<a href='" & Cl.Web_info(4) & "'>" & Cl.Web_info(0) & "</a>&nbsp;&gt;&gt;&nbsp;<a href='" & Cl.WebDir & Cl.ChannelDir & "'>" & Cl.ChannelName & "</a>"
	Cl.Title = Cl.NoHtml(Cl.ChannelName) & " " & Cl.GotTopic(Cl.ChannelReadMe,50) & "[" & Cl.Web_info(1) & "]"
	if keyword<>"" then keyword=Cl.ReplaceBadChar(keyword)
	if PhotoID>0 then
		Set rs= Cl.Execute("select * from Cl_Photo where ChannelID=" & ChannelID & " and Deleted=False and Passed=True and PhotoID=" & PhotoID & "")
		if rs.bof and rs.eof then Cl.OutErr(Replace(Template.Strings(0),"{%channelitemname%}",Cl.ChannelItemName))
		ClassID=rs("ClassID"):SpecialID=rs("SpecialID"):InfoTitle=rs("PhotoName")
		if rs("Hot")=False then
			if rs("hits")>=Clng(Cl.Web_Setting(14)) then Cl.Execute("Update Cl_Photo Set Hot=True where PhotoID=" & PhotoID & "")
		end if
	end if
	if ClassID>0 then
		sql="select ClassName,ParentID,ParentPath,ClassDir,ParentDir,RootID,Depth,Child,arrChildID,BrowsePurview,VipUser,StyleID,CssID From Cl_Class where ChannelID="&ChannelID&" and ClassID=" & ClassID
		set tClass=Cl.Execute(sql)
		if tClass.bof and tClass.eof then Cl.OutErr(Template.Strings(1))
		ClassName	= tClass(0) : ParentID	= tClass(1) : ParentPath= tClass(2)
		ClassDir	= tClass(3) : ParentDir	= tClass(4) : RootID	= tClass(5)
		Depth		= tClass(6) : Child		= tClass(7)	: arrChildID= tClass(8)
		BrowsePurview=tClass(9) : VipUser	= tClass(10): TStyleID	= tClass(11) : TCssID=tClass(12)
		if TStyleID > 0 or TCssID > -1 then
			If TStyleID > 0 then Cl.StyleID = TStyleID
			If TCssID > -1	then Cl.CssID	= TCssID
			Cl.LoadTempLates(Cl.Channel_Setting(4))
		end if
		if ParentID>0 then
			dim sqlPath,rsPath
			sqlPath="select ClassID,ClassName,ParentPath,ClassDir,ParentDir From Cl_Class where ChannelID="&ChannelID&" and ClassID in (" & ParentPath & ") order by Depth"
			set rsPath=Cl.Execute(sqlPath)
			do while not rsPath.eof
				CurrentPath=CurrentPath & "&nbsp;&gt;&gt;&nbsp;<a href='" & Cl.WebDir & Cl.GetClassUrl(Cl.Channel_Setting(11),Cl.HtmlDir,Cl.Channel_Setting(4),rsPath(2),rsPath(0),rsPath(4),rsPath(3),Cl.Channel_Setting(10),Cl.Channel_Setting(13)) & "'>" & rsPath(1) & "</a>"
				rsPath.movenext
			loop
			set rsPath=Nothing
		end if
		CurrentPath=CurrentPath & "&nbsp;&gt;&gt;&nbsp;<a href='" & Cl.WebDir & Cl.GetClassUrl(Cl.Channel_Setting(11),Cl.HtmlDir,Cl.Channel_Setting(4),ParentPath,ClassID,ParentDir,ClassDir,Cl.Channel_Setting(10),Cl.Channel_Setting(13)) & "'>" & ClassName & "</a>"
	end if
End Sub
'Rem 图片
Function GetPhoto(Byval sChannelID,Byval sClassID,Byval sSpecialID,Byval TopNum,Byval IncludeChild,Byval ShowType, _
Byval ColsNum,Byval IsHot,Byval IsElite,Byval DateNum,Byval OrderType,Byval Style1,Byval Style2,Byval Style3)
	Dim JsSQL,sHTML,sTitleMaxLen,TitleStr,LinkUrl,FileType
	Dim Author,AuthorName,AuthorEmail
	Dim SystemTopDir,SystemDir
	Dim Rs,i
	On Error Resume Next
	SystemTopDir	= "http://"&Request.servervariables("Server_Name")
	SystemDir		= SystemTopDir & Cl.WebDir
	sChannelID		= Clng(sChannelID)
	sClassID		= Clng(sClassID)
	sSpecialID		= Clng(sSpecialID)
	TopNum			= Clng(TopNum)
	IncludeChild	= CBool(IncludeChild)
	ShowType		= Clng(ShowType)
	ColsNum			= Clng(ColsNum)
	IsHot			= CBool(IsHot)
	IsElite			= CBool(IsElite)
	DateNum			= CLng(DateNum)
	OrderType		= CLng(OrderType)
	Style1			= Trim(Style1)
	Style2			= Trim(Style2)
	Style3			= Trim(Style3)
	if Err then Err.Clear : GetPhoto="GetPhoto参数错误。":Exit Function
	On Error GoTo 0
	Cl.GetChannelSetting(sChannelID)
	if TopNum > 0 then
		JsSQL="select top " & TopNum & " "
	else
		JsSQL="select top 100 "
	end if
	JsSQL=JsSQL & " P.PhotoID,P.ClassID,C.ClassName,C.ParentPath,C.ClassDir,C.ParentDir,P.PhotoName,P.Prefixion,P.Author,P.AuthorEmail,P.Editor,P.Keyword,P.Hits,P.DayHits,P.WeekHits,P.MonthHits,P.UpdateTime,P.PhotoPicUrl,P.OnTop,P.Hot,P.Elite,P.Passed,P.PhotoIntro,P.PhotoLevel,P.PhotoPoint,P.Stars,P.IsHtml,P.HtmlFileUrl from Cl_Photo P"
	JsSQL=JsSQL & " inner join Cl_Class C on P.ClassID=C.ClassID where P.Deleted=False and P.Passed=True and P.ChannelID="&sChannelID&""
	if sClassID>0 then
		if IncludeChild=True then
			Dim tClass
			set tClass=Cl.Execute("select ClassID,ParentPath,arrChildID From Cl_Class where ClassID=" & sClassID)
			if tClass.bof and tClass.eof then
				GetPhoto="找不到指定的栏目。" : set tClass=Nothing : Exit Function
			else
				JsSQL=JsSQL & " and P.ClassID in (" & tClass(2) & ")"
			end if
			set tClass=Nothing
		else
			JsSQL=JsSQL & " and P.ClassID=" & sClassID & ""
		end if
	end if
	if sSpecialID>0 then JsSQL=JsSQL & " and P.SpecialID like '%" & sSpecialID & "%'"
	if ShowType >= 2 then JsSQL=JsSQL & " and P.PhotoPicUrl<>''"
	if IsHot=True then JsSQL=JsSQL & " and P.Hot=True"
	if IsElite=True then JsSQL=JsSQL & " and P.Elite=True"
	if DateNum>0 then
		JsSQL=JsSQL & " and DATEDIFF('d',P.UpdateTime,"&SQLNowString&")<=" & DateNum & " "
	end if
	JsSQL=JsSQL & " order by P.OnTop asc"
	Select Case OrderType
	Case 1 : JsSQL=JsSQL & " ,P.PhotoID desc"
	Case 2 : JsSQL=JsSQL & " ,P.PhotoID asc"
	Case 3 : JsSQL=JsSQL & " ,P.UpDateTime desc, P.PhotoID desc"
	Case 4 : JsSQL=JsSQL & " ,P.UpDateTime asc, P.PhotoID desc"
	Case 5 : JsSQL=JsSQL & " ,P.Hits desc, P.PhotoID desc"
	Case 6 : JsSQL=JsSQL & " ,P.Hits asc, P.PhotoID desc"
	Case else : JsSQL=JsSQL & " ,P.PhotoID desc"
	End Select
	set Rs=server.createObject("Adodb.recordset")
	OpenConn : Rs.open JsSQL,Conn,1,1
	if Rs.bof and Rs.eof then 
		GetPhoto = "没有任何"&Cl.Channel_Setting(2)&"!"
		Rs.close:set Rs=Nothing : Exit Function
	End if
	JsSQL=Rs.GetRows(-1)
	Rs.close:set Rs=Nothing
	Dim TempBody
	Dim regEx,Matches,Match,TempStr
	Dim PropertyImg,ClassFileUrl,sImgUrl
	TempBody="":sHTML=""
	Set regEx	= New RegExp
	regEx.Pattern = "(\{%)(.[^\{]*)(\%\})"
	regEx.IgnoreCase = True
	regEx.Global = True
	For i=0 to Ubound(JsSQL,2)
		if JsSQL(26,i)=True and Clng(Cl.Channel_Setting(10))=1 then
			LinkUrl = SystemDir & JsSQL(27,i)
		else
			LinkUrl = SystemDir & Cl.Channel_Setting(4) & "/PhotoShow.asp?PhotoID=" & JsSQL(0,i)
		end if
		if JsSQL(18,i)=True then
			PropertyImg = "<img src=""" & ChkPicUrl(SysTemDir,SysTemTopDir,Cl.mainpic(19)) & """ alt=""固顶"" />"
		elseif JsSQL(20,i)=True then
			PropertyImg = "<img src=""" & ChkPicUrl(SysTemDir,SysTemTopDir,Cl.mainpic(18)) & """ alt=""推荐"" />"
		else
			PropertyImg = "<img src=""" & ChkPicUrl(SysTemDir,SysTemTopDir,Cl.mainpic(17)) & """ alt=""普通"" />"
		end if
		ClassFileUrl = SystemDir & Cl.GetClassUrl(Cl.Channel_Setting(11),Cl.HtmlDir,Cl.Channel_Setting(4),JsSQL(3,i),JsSQL(1,i),JsSQL(5,i),JsSQL(4,i),Cl.Channel_Setting(10),Cl.Channel_Setting(13))
		if ShowType >= 2 then
			FileType=right(lcase(JsSQL(17,i)),3)
			JsSQL(17,i) = ChkPicUrl(SysTemDir,SysTemTopDir,JsSQL(17,i))
			Select Case FileType
			Case "swf"
				sImgUrl = "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"" width=""{%ImgWidth%}"" height=""{%ImgHeight%}""><param name=""movie"" value=""" & JsSQL(17,i) & """><param name=""quality"" value=""high""><embed src=""" & JsSQL(17,i) & """ pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""{%ImgWidth%}"" height=""{%ImgHeight%}""></embed></object>"
			Case "jpg", "bmp", "png", "gif"
				sImgUrl = "<img src=""" & JsSQL(17,i) & """ width=""{%ImgWidth%}"" height=""{%ImgHeight%}"" border=0>"
			Case Else
				sImgUrl = "<img src=""" & SystemDir & "images/NoPic2.jpg"" width=""{%ImgWidth%}"" height=""{%ImgHeight%}"" border=0>"
			End Select
		end if
		TempBody	= Style2
		TempBody	= Replace(TempBody,"{%InfoID%}",JsSQL(0,i))
		TempBody	= Replace(TempBody,"{%Prefixion%}",JsSQL(7,i)&"")
		TempBody	= Replace(TempBody,"{%PropertyImg%}",PropertyImg)
		TempBody	= Replace(TempBody,"{%LinkUrl%}",LinkUrl)
		TempBody	= Replace(TempBody,"{%ClassID%}",JsSQL(1,i))
		TempBody	= Replace(TempBody,"{%ClassName%}",JsSQL(2,i))
		TempBody	= Replace(TempBody,"{%ClassUrl%}",ClassFileUrl)
		TempBody	= Replace(TempBody,"{%AuthorName%}",JsSQL(8,i)&"")
		TempBody	= Replace(TempBody,"{%AuthorEmail%}",JsSQL(9,i)&"")
		TempBody	= Replace(TempBody,"{%Hits%}",JsSQL(12,i))
		TempBody	= Replace(TempBody,"{%DayHits%}",JsSQL(13,i))
		TempBody	= Replace(TempBody,"{%WeekHits%}",JsSQL(14,i))
		TempBody	= Replace(TempBody,"{%MonthHits%}",JsSQL(15,i))
		Set Matches = regEx.Execute(TempBody)
		For Each Match in Matches
			TempStr = Replace(Match.Value,"{%","")
			TempStr = Replace(TempStr,"%}","")
			TempStr = Replace(TempStr,"(",",")
			TempStr = Replace(TempStr,")","")
			TempStr = Replace(TempStr,"""","")
			TempStr = Split(Lcase(TempStr),",")
			Select Case TempStr(0)
			Case "title"
				TitleStr = Cl.GotTopic(JsSQL(6,i),TempStr(1))
				TempBody = Replace(TempBody,Match.Value,TitleStr)
			Case "imgurl"
				sImgUrl	 = Replace(sImgUrl,"{%ImgWidth%}",TempStr(1))
				sImgUrl	 = Replace(sImgUrl,"{%ImgHeight%}",TempStr(2))
				TempBody = Replace(TempBody,Match.Value,sImgUrl)
			Case "intro"
				TempBody = Replace(TempBody,Match.Value,Left(Cl.NoHtml(JsSQL(22,i)),TempStr(1)))
			Case "updatetime"
				TempBody = Replace(TempBody,Match.Value,Cl.Format_Time(JsSQL(16,i),TempStr(1)))
			End Select
		Next
		sHTML = sHTML & TempBody
		if (i+1) mod ColsNum=0 then sHTML = sHTML & Style3
	Next
	GetPhoto=Replace(Style1,"{%ContentBody%}",sHTML)
	JsSQL=Empty
End Function
'=================================================
'过程名：ShowClassPhoto(sChannelID,sClassID,ModNum,TopNum)
'参  数：
'		sChannelID	----	频道ID
'		sClassID	----	指定栏目，多个用“|”分隔，不指定请留空或0
'		ModNum      ---		多少个换行
'		TopNum      ---		最多显示记录数
'=================================================
Function ShowClassPhoto(Byval sChannelID,Byval sClassID,Byval ModNum,Byval TopNum)
	dim sqlRoot,rsRoot,ClassCount,iClassID
	Dim sTemp,strValue
	sChannelID	= Cl.ChkClng(sChannelID)
	sTemp		= ""
	sClassID	= Trim(sClassID)
	ModNum		= Cl.ChkClng(ModNum)
	if sClassID="" or sClassID="0" then
		TopNum		= Cl.ChkClng(TopNum)
		if TopNum=0 then TopNum = 6
		sqlRoot="select Top "&TopNum&" ClassID,ClassName,ParentPath,ClassDir,ParentDir,RootID,Child,arrChildID,Readme From Cl_Class where ChannelID="&sChannelID&" and ParentID=0 and IsElite=True and IsOuter=0 order by RootID"
	Else
		sqlRoot="select ClassID,ClassName,ParentPath,ClassDir,ParentDir,RootID,Child,arrChildID,Readme From Cl_Class where ChannelID="&sChannelID&" and IsElite=True and IsOuter=0 and ClassID In ("&Replace(sClassID,"|",",")&") order by RootID"
	End if
	Set rsRoot= Cl.Execute(sqlRoot)
	if rsRoot.bof and rsRoot.eof then
		sTemp="还没有任何栏目，请首先添加栏目。"
		rsRoot.Close:Set rsRoot=Nothing:Exit Function
	end if
	sqlRoot=rsRoot.GetRows(-1)
	rsRoot.Close:Set rsRoot=Nothing
	Cl.GetChannelSetting(sChannelID)
	Cl.LoadTempLates(Cl.Channel_Setting(4))
	for iClassID=0 to Ubound(sqlRoot,2)
		strValue=Replace(Template.html(8),"{%channelid%}",sChannelID)
		strValue=Replace(strValue,"{%classid%}",sqlRoot(0,iClassID))
		strValue=Replace(strValue,"{%classtitle%}",sqlRoot(8,iClassID)&"")
		strValue=Replace(strValue,"{%classname%}",sqlRoot(1,iClassID))
		strValue=Replace(strValue,"{%classfileurl%}",Cl.WebDir & Cl.GetClassUrl(Cl.Channel_Setting(11),Cl.HtmlDir,Cl.Channel_Setting(4),sqlRoot(2,iClassID),sqlRoot(0,iClassID),sqlRoot(4,iClassID),sqlRoot(3,iClassID),Cl.Channel_Setting(10),Cl.Channel_Setting(13)))
		strValue=Cl.ReplaceFlag(strValue,"showphoto","")
		if ((iClassID+1) mod modnum) = 0 then
			strValue = strValue & Split(Template.html(9),"||")(1)
		else
			strValue = strValue & Split(Template.html(9),"||")(0)
		end if
		sTemp=sTemp & strValue
	Next
	ShowClassPhoto=Replace(Template.html(7),"{%classphotobody%}",sTemp)
	sqlRoot=Empty
End Function

'====================================================================================================
'过程：ShowPicPhoto(sChannelID,sClassID,sSpecialID,TopNum,TitleLen,ShowType,Cols,ImgWidth,ImgHeight,ContentLen,IsHot,IsElite)
'参数：
'	sChannelID  ------  频道ID
'	sClassID    ------  栏目ID(0为所有栏目,若大于0，则调用指定栏目及其子栏目)
'	sSpecialID  ------  专题ID(0为所有栏目,若大于0，则调用指定专题)
'	TopNum      ------  最多显示多少篇
'	TitleLen    ------  标题最多字符数
'	ShowType    ------  显示方式。0(图),1(图+标),2(图+标+内),3(图+幻),4(图+标+幻)
'	Cols        ------  列数。超过此列数就换行
'	ImgWidth    ------  图片宽度
'	ImgHeight   ------  图片高度
'	ContentLen  ------  内容最多字符数
'	IsHot       ------  是否是热门(True为是，False为否)
'	IsElite     ------  是否是推荐(True为是，False为否)
'====================================================================================================
Function ShowPicPhoto(Byval sChannelID,Byval sClassID,Byval sSpecialID, _
	Byval TopNum,Byval TitleLen,Byval ShowType,Byval Cols,Byval ImgWidth, _
	Byval ImgHeight,Byval ContentLen,Byval IsHot,Byval IsElite)
	On Error Resume Next
	sChannelID	= Clng(sChannelID)	: sClassID		= Clng(sClassID)
	sSpecialID	= Clng(sSpecialID)	: TopNum		= Clng(TopNum)
	TitleLen	= Clng(TitleLen)	: ShowType		= Clng(ShowType)
	Cols		= Clng(Cols)		: ImgWidth		= Clng(ImgWidth)
	ImgHeight	= Clng(ImgHeight)	: ContentLen	= Clng(ContentLen)
	IsHot		= CBool(IsHot)		: IsElite		= CBool(IsElite)
	if Err then Err.Clear : ShowPicPhoto="ShowPicPhoto参数错误。":Exit Function
	On Error GoTo 0
	Cl.GetChannelSetting(sChannelID)
	dim rsPic,sqlPic,tClass,j,strPic
	if TopNum<=0 then
		sqlPic="Select "
	else
		sqlPic="Select top "&TopNum&" "
	end if
	sqlPic=sqlPic & " PhotoID,ClassID,PhotoName,Author,AuthorEmail,Editor,Keyword,Hits,DayHits,WeekHits,MonthHits,UpdateTime,PhotoPicUrl,OnTop,Elite,Passed,PhotoIntro,PhotoLevel,PhotoPoint,Stars,IsHtml,HtmlFileUrl from Cl_Photo where Deleted=False and Passed=True and ChannelID="&sChannelID&" and PhotoPicUrl<>'' "
	if sClassID>0 then
		set tClass=Cl.Execute("select ClassID,Child,ParentPath,arrChildID from Cl_Class where ChannelID="&sChannelID&" and ClassID=" & sClassID)
		if not(tClass.bof and tClass.eof) then
			if tClass(1)>0 then
				sqlPic=sqlPic & " and ClassID in (" & tClass(3) & ")"
			else
				sqlPic=sqlPic & " and ClassID=" & sClassID
			end if
		else
			sqlPic=sqlPic & " and ClassID=" & sClassID
		end if
		set tClass=Nothing
	end if
	if sSpecialID>0 then sqlPic=sqlPic & " and SpecialID Like '%" & sSpecialID & "%'"
	if IsHot=True then sqlPic=sqlPic & " and Hot=True "
	if IsElite=True then sqlPic=sqlPic & " and Elite=True "
	'if IsSqlDataBase=1 then
	sqlPic=sqlPic & " order by OnTop Asc,UpdateTime desc,PhotoID desc"
	Set rsPic= Server.CreateObject("ADODB.Recordset")
	OpenConn : rsPic.open sqlPic,Conn,1,1
	strPic= "<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" align=""center""><tr valign=""top"">"
	if rsPic.bof and rsPic.eof then
		strPic = strPic & "<td align=""center""><img src=""" & Cl.WebDir & "images/NoPic.gif"" width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0""><br />没有"&Cl.Channel_Setting(2)&"</td>"
		rsPic.Close : Set rsPic = Nothing
	else
		dim FileType,TitleStr,LinkUrl
		if TopNum<=0 or TopNum>=100 then
			TotalPut=rsPic.recordcount
			if (TotalPut mod MaxPerPage)=0 then
				TotalPages = TotalPut \ MaxPerPage
			else
				TotalPages = TotalPut \ MaxPerPage + 1
			end if
			if CurrentPage > TotalPages then CurrentPage=TotalPages
			if CurrentPage < 1 then CurrentPage=1
			rsPic.move (CurrentPage-1)*MaxPerPage
			sqlPic = rsPic.GetRows(MaxPerPage)
		else
			sqlPic=rsPic.GetRows(-1)
		end if
		rsPic.Close : Set rsPic = Nothing
		Select Case ShowType
		Case 0
			for j=0 to Ubound(sqlPic,2)
				if sqlPic(20,j) and Clng(Cl.Channel_Setting(10))=1 then
					LinkUrl=Cl.WebDir & sqlPic(21,j)
				else
					LinkUrl=Cl.WebDir & Cl.Channel_Setting(4) & "/PhotoShow.asp?PhotoID=" & sqlPic(0,j)
				end if
				strPic = strPic & "<td align=""center"">"
				FileType=right(lcase(sqlPic(12,j)),3)
				strPic = strPic & "<a href=""" & LinkUrl & """ title=""标题：" & sqlPic(2,j) & vbcrlf & "作者：" & sqlPic(3,j) & vbcrlf & "更新：" & sqlPic(11,j) & vbcrlf & "点击：" & sqlPic(7,j) & """ target=""_blank"">"
				sqlPic(12,j)=Cl.ReplaceDir(sqlPic(12,j))
				Select Case FileType
				Case "swf"
					strPic = strPic & "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"" width=""" & ImgWidth & """ height=""" & ImgHeight & """><param name=""movie"" value=""" & sqlPic(12,j) & """><param name=""quality"" value=""high""><embed src=""" & sqlPic(12,j) & """ pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""" & ImgWidth & """ height=""" & ImgHeight & """></embed></object>"
				Case "jpg", "bmp", "png", "gif"
					strPic = strPic & "<img src=""" & sqlPic(12,j) & """ width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
				Case else
					strPic = strPic & "<img src=""" & Cl.WebDir & "images/NoPic.gif"" width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
				end Select
				strPic = strPic & "</a></td>"
				if (j+1) Mod Cols=0 then strPic = strPic & "</tr><tr valign=""top"">"
			Next
		Case 1
			for j=0 to Ubound(sqlPic,2)
				if sqlPic(20,j) and Clng(Cl.Channel_Setting(10))=1 then
					LinkUrl=Cl.WebDir & sqlPic(21,j)
				else
					LinkUrl=Cl.WebDir & Cl.Channel_Setting(4) & "/PhotoShow.asp?PhotoID=" & sqlPic(0,j)
				end if
				strPic = strPic & "<td align=""center"">"
				FileType=right(lcase(sqlPic(12,j)),3)
				TitleStr=Cl.GotTopic(sqlPic(2,j),TitleLen)
				strPic = strPic & "<a href=""" & LinkUrl & """ title=""标题：" & sqlPic(2,j) & vbcrlf & "作者：" & sqlPic(3,j) & vbcrlf & "更新：" & sqlPic(11,j) & vbcrlf & "点击：" & sqlPic(7,j) & """ target=""_blank"">"
				sqlPic(12,j)=Cl.ReplaceDir(sqlPic(12,j))
				Select Case FileType
				Case "swf"
					strPic = strPic & "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"" width=""" & ImgWidth & """ height=""" & ImgHeight & """><param name=""movie"" value=""" & sqlPic(12,j) & """><param name=""quality"" value=""high""><embed src=""" & sqlPic(12,j) & """ pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""" & ImgWidth & """ height=""" & ImgHeight & """></embed></object>"
				Case "jpg", "bmp", "png", "gif"
					strPic = strPic & "<img src=""" & sqlPic(12,j) & """ width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
				Case else
					strPic = strPic & "<img src=""" & Cl.WebDir & "images/NoPic.gif"" width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
				end Select
				strPic = strPic & "<br />" & TitleStr & "</a>"
				strPic = strPic & "</td>"
				if (j+1) Mod Cols=0 then strPic = strPic & "</tr><tr valign=""top"">"
			Next
		Case 2
			for j=0 to Ubound(sqlPic,2)
				if sqlPic(20,j) and Clng(Cl.Channel_Setting(10))=1 then
					LinkUrl=Cl.WebDir & sqlPic(21,j)
				else
					LinkUrl=Cl.WebDir & Cl.Channel_Setting(4) & "/PhotoShow.asp?PhotoID=" & sqlPic(0,j)
				end if
				strPic = strPic & "<td align=""center"">"
				FileType=right(lcase(sqlPic(12,j)),3)
				TitleStr=Cl.GotTopic(sqlPic(2,j),TitleLen)
				strPic = strPic & "<a href=""" & LinkUrl & """ title=""标题：" & sqlPic(2,j) & vbcrlf & "作者：" & sqlPic(3,j) & vbcrlf & "更新：" & sqlPic(11,j) & vbcrlf & "点击：" & sqlPic(7,j) & """ target=""_blank"">"
				sqlPic(12,j)=Cl.ReplaceDir(sqlPic(12,j))
				Select Case FileType
				Case "swf"
					strPic = strPic & "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"" width=""" & ImgWidth & """ height=""" & ImgHeight & """><param name=""movie"" value=""" & sqlPic(12,j) & """><param name=""quality"" value=""high""><embed src=""" & sqlPic(12,j) & """ pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""" & ImgWidth & """ height=""" & ImgHeight & """></embed></object>"
				Case "jpg", "bmp", "png", "gif"
					strPic = strPic & "<img src=""" & sqlPic(12,j) & """ width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
				Case else
					strPic = strPic & "<img src=""" & Cl.WebDir & "images/NoPic.gif"" width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
				end Select
				strPic = strPic & "<br />" & TitleStr & "</a>"
				strPic = strPic & "</td><td valign=""top"" algin=""center"" class=""left""><a href=""" & LinkUrl & """>" & left(Cl.NoHtml(sqlPic(16,j)),ContentLen) & "……</a></td>"
				if (j+1) Mod Cols=0 then strPic = strPic & "</tr><tr valign=""top"">"
			Next
		Case 3, 4
			Dim sImgID
			sImgID=Cl.CreatePass(3) & "Cl" & ImgWidth & ImgHeight & ContentLen' & IsHot & IsElite
			strPic = strPic & "<script type=""text/javascript"">" & vbcrlf
			strPic = strPic & "<!--" & vbcrlf
			strPic = strPic & "var AImg"&sImgID&"=new Array();" & vbcrlf
			strPic = strPic & "var AImg"&sImgID&"link=new Array();" & vbcrlf
			strPic = strPic & "var AImg"&sImgID&"title=new Array();" & vbcrlf
			strPic = strPic & "var adNum"&sImgID&"=0;" & vbcrlf
			Dim FirstPicUrl
			for j=0 to Ubound(sqlPic,2)
				FileType=right(lcase(sqlPic(12,j)),3)
				TitleStr=Cl.GotTopic(sqlPic(2,j),TitleLen)
				if sqlPic(20,j) and Clng(Cl.Channel_Setting(10))=1 then
					LinkUrl=Cl.WebDir & sqlPic(21,j)
				else
					LinkUrl=Cl.WebDir & Cl.Channel_Setting(4) & "/PhotoShow.asp?PhotoID=" & sqlPic(0,j)
				end if
				strPic = strPic & "AImg"&sImgID&"link[" & cStr(j) & "]=""" & LinkUrl & """;" & vbcrlf
				if fileType="jpg" or fileType="bmp" or fileType="png" or fileType="gif" then
					strPic = strPic & "AImg"&sImgID&"[" & cStr(j) & "]=""" & Cl.ReplaceDir(sqlPic(12,j)) & """;" & vbcrlf
				else
					strPic = strPic & "AImg"&sImgID&"[" & cStr(j) & "]=""" & Cl.WebDir & "images/NoPic.gif"";" & vbcrlf
				end if
				if j=0 then FirstPicUrl=Cl.ReplaceDir(sqlPic(12,j))
				strPic = strPic & "AImg"&sImgID&"title[" & cStr(j) & "]=""" & Replace(TitleStr,Chr(34),"\" & Chr(34)) & """;" & vbcrlf
			Next
			strPic = strPic & "var preloadimg"&sImgID&"=new Array();" & vbcrlf
			strPic = strPic & "for (i=1;i<AImg"&sImgID&".length;i++){" & vbcrlf
			strPic = strPic & "preloadimg"&sImgID&"[i]=new Image();" & vbcrlf
			strPic = strPic & "preloadimg"&sImgID&"[i].src=AImg"&sImgID&"[i];}" & vbcrlf
			strPic = strPic & "function set"&sImgID&"Transition()" & vbcrlf
			strPic = strPic & "{" & vbcrlf
			strPic = strPic & "if (document.all){" & vbcrlf
			strPic = strPic & "AImg"&sImgID&"rotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);" & vbcrlf
			strPic = strPic & "AImg"&sImgID&"rotator.filters.revealTrans.apply();" & vbcrlf
			strPic = strPic & "}" & vbcrlf
			strPic = strPic & "}" & vbcrlf
			strPic = strPic & "function play"&sImgID&"Transition()" & vbcrlf
			strPic = strPic & "{" & vbcrlf
			strPic = strPic & "if (document.all)" & vbcrlf
			strPic = strPic & "AImg"&sImgID&"rotator.filters.revealTrans.play()" & vbcrlf
			strPic = strPic & "}" & vbcrlf
			strPic = strPic & "function next"&sImgID&"Img()" & vbcrlf
			strPic = strPic & "{" & vbcrlf
			strPic = strPic & "if(adNum"&sImgID&"<AImg"&sImgID&".length-1)adNum"&sImgID&"++ ;" & vbcrlf
			strPic = strPic & "else adNum"&sImgID&"=0;" & vbcrlf
			strPic = strPic & "set"&sImgID&"Transition();" & vbcrlf
			strPic = strPic & "document.images.AImg"&sImgID&"rotator.src=AImg"&sImgID&"[adNum"&sImgID&"];" & vbcrlf
			strPic = strPic & "play"&sImgID&"Transition();" & vbcrlf
			strPic = strPic & "title"&sImgID&".innerHTML=""<A href='"" + AImg"&sImgID&"link[adNum"&sImgID&"] + ""'>"" + AImg"&sImgID&"title[adNum"&sImgID&"] +""</a>"";" & vbcrlf
			strPic = strPic & "theTimer=setTimeout(""next"&sImgID&"Img()"", 5000);" & vbcrlf
			strPic = strPic & "}" & vbcrlf
			strPic = strPic & "function jump2"&sImgID&"url()" & vbcrlf
			strPic = strPic & "{" & vbcrlf
			strPic = strPic & "jumpUrl=AImg"&sImgID&"link[adNum"&sImgID&"];" & vbcrlf
			strPic = strPic & "jumpTarget=""_blank"";" & vbcrlf
			strPic = strPic & "if (jumpUrl != ''){" & vbcrlf
			strPic = strPic & "if (jumpTarget != '')window.open(jumpUrl,jumpTarget);" & vbcrlf
			strPic = strPic & "else location.href=jumpUrl;" & vbcrlf
			strPic = strPic & "}" & vbcrlf
			strPic = strPic & "}" & vbcrlf
			strPic = strPic & "function display"&sImgID&"Msg()" & vbcrlf
			strPic = strPic & "{" & vbcrlf
			strPic = strPic & "status=AImg"&sImgID&"link[adNum"&sImgID&"];" & vbcrlf
			strPic = strPic & "document.returnValue = true;" & vbcrlf
			strPic = strPic & "}" & vbcrlf
			strPic = strPic & "//-->" & vbcrlf
			strPic = strPic & "</script>" & vbcrlf
			strPic = strPic & "<td align=""center"">" & vbcrlf
			strPic = strPic & "<A onmouseover=""display"&sImgID&"Msg();return document.returnValue;"" href=""javascript:jump2"&sImgID&"url();""><IMG style=""FILTER: revealTrans(duration=2,transition=20)"" width='" & ImgWidth & "' height='" & ImgHeight & "' border=0 src=""" & FirstPicUrl & """ name=AImg"&sImgID&"rotator></A>" & vbcrlf
			strPic = strPic & "</td>" & vbcrlf
			if ShowType=4 then
				strPic = strPic & "</tr><tr><TD id=""title"&sImgID&""" align=""center""></td>" & vbcrlf
			else
				strPic = strPic & "</tr><tr><TD id=""title"&sImgID&""" align=""center"" style=""display:none""></td>" & vbcrlf
			end if
			strPic = strPic & "<script type=""text/javascript"">title"&sImgID&".innerHTML=""<A href='"" + AImg"&sImgID&"link[0] + ""'>"" + AImg"&sImgID&"title[0] +""</a>"";setTimeout(""next"&sImgID&"Img()"", 3000);" & vbcrlf
			strPic = strPic & "</script>"
		end Select
		sqlPic=Empty
	end if
	strPic = strPic &  "</tr></table>"
	ShowPicPhoto=strPic
End Function

'====================================================================================================
'过程：ShowPhoto(sChannelID,sClassID,sSpecialID,TopNum,TitleLen,ShowClassName,ShowProperty,ShowPrefix,ShowAuthor,ShowDateType,ShowHits,ShowHot,IsElite,IsHot,UserName,CssStyle)
'参数：
'	sChannelID		------  频道ID
'	sClassID		------  栏目ID(0为全部，如果大于0，则调用指定栏目及其子栏目)
'	sSpecialID		------  专题ID(0为全部，如果大于0，刚调用指定专题)
'	TopNum			------  最多记录数，0为全部(用于分页显示)
'	TitleLen		------  标题最多字符数
'	ShowClassName	------  是否显示栏目名称(True为显示，False为不显示)
'	ShowProperty	------  是否显示文章属性(固顶/推荐/普通)，(True为显示，False为不显示)
'	ShowPrefix		------  是否显示前缀如：[推荐][图文][注意]字样(True为显示，False为不显示)
'	ShowAuthor		------  是否显示文章作者，True为显示，False为不显示)
'	ShowDateType	------  显示更新日期的样式
'							---- 0(不显示)
'							---- 1(2004-10-01 23:45:45)
'							---- 2(年-月-日 时:分:秒)
'							---- 3(2004-10-01)
'							---- 4(2004\10\01)
'							---- 5(10-01 23:45)
'							---- 6(2004年10月01日)
'							---- 7(10-01)
'							---- 8(20041001234545)
'	ShowHits		------  是否显示文章点击数(True为显示，False为不显示)
'	ShowHot			------  是否显示热门文章标志(True为显示，False为不显示)
'	IsHot			------  是否热门(True为是，False为否)
'	IsElite			------  是否推荐(True为是，False为否)
'	UserName		------  指定某用户(不指定请留空值或0)
'	CssStyle        ------  CSS样式
'====================================================================================================
Function ShowPhoto(Byval sChannelID,Byval sClassID,Byval sSpecialID, _
	Byval TopNum,Byval TitleLen,Byval ShowClassName,Byval ShowProperty, _
	Byval ShowPrefix,Byval ShowAuthor,Byval ShowDateType,Byval ShowHits, _
	Byval ShowHot,Byval IsHot,Byval IsElite,Byval UserName,Byval CssStyle)
	On Error ReSume Next
	sChannelID		= Clng(sChannelID)		: sClassID		= Clng(sClassID)
	sSpecialID		= Clng(sSpecialID)		: TopNum		= Clng(TopNum)
	TitleLen		= Clng(TitleLen)		: ShowClassName	= CBool(ShowClassName)
	ShowProperty	= CBool(ShowProperty)	: ShowPrefix	= CBool(ShowPrefix)
	ShowAuthor		= CBool(ShowAuthor)		: ShowDateType	= Clng(ShowDateType)
	ShowHits		= CBool(ShowHits)		: ShowHot		= CBool(ShowHot)
	IsHot			= CBool(IsHot)			: IsElite		= CBool(IsElite)
	UserName		= Trim(UserName)		: CssStyle		= Trim(CssStyle)
	if Err then Err.Clear : ShowPhoto="ShowPhoto参数错误。" : Exit Function
	On Error GoTo 0
	Cl.GetChannelSetting(sChannelID)
	Dim SQLInfo
	if TopNum<=0 then
		SqlInfo="Select "
	else
		SqlInfo="Select Top "&TopNum&" "
	end if
	SqlInfo = SqlInfo & "P.PhotoID,P.ClassID,C.ClassName,C.ParentPath,C.ClassDir,C.ParentDir,P.PhotoName,P.Prefixion,P.Author,P.AuthorEmail,P.Editor,P.Keyword,P.Hits,P.DayHits,P.WeekHits,P.MonthHits,P.UpdateTime,P.PhotoPicUrl,P.OnTop,P.Hot,P.Elite,P.Passed,P.PhotoLevel,P.PhotoPoint,P.Stars,P.IsHtml,P.HtmlFileUrl from Cl_Photo P Inner Join Cl_Class C On P.ClassID=C.ClassID where P.Deleted=False and P.Passed=True and P.ChannelID="&sChannelID&" "
	if sClassID>0 then
		Dim tClass
		Set tClass=Cl.Execute("select ClassID,Child,ParentPath,arrChildID from Cl_Class where ChannelID="&sChannelID&" and ClassID=" & sClassID)
		if not(tClass.bof and tClass.eof) then
			if tClass(1)>0 then
				SqlInfo=SqlInfo & " and P.ClassID in (" & tClass(3) & ")"
			else
				SqlInfo=SqlInfo & " and P.ClassID=" & sClassID
			end if
		else
			SqlInfo=SqlInfo & " and P.ClassID=" & sClassID
		end if
		Set tClass=Nothing
	end if
	if sSpecialID>0 then SqlInfo=SqlInfo & " and P.SpecialID Like '%" & sSpecialID & "%'"
	if IsElite=True then SqlInfo=SqlInfo & " and P.Elite=True"
	if IsHot=True then SqlInfo=SqlInfo & " and P.Hot=True"
	if UserName<>"" and UserName<>"0" then SqlInfo=SqlInfo &  " and P.Editor='" & UserName & "'"
	'if IsSqlDataBase=1 then
	SqlInfo=SqlInfo & " order by P.OnTop Asc,P.UpdateTime desc,P.PhotoID desc"
	Set rsInfo= Server.CreateObject("ADODB.Recordset")
	OpenConn : rsInfo.open SqlInfo,Conn,1,1
	if rsInfo.bof and  rsInfo.eof then
		'TotalPut=0
		ShowPhoto="<br /><li>没有任何"&Cl.Channel_Setting(2)&"</li>"
		rsInfo.close:set rsInfo=Nothing : Exit Function
	End if
	if TopNum<=0 or TopNum>=100 then
		TotalPut=rsInfo.recordcount
		if (TotalPut mod MaxPerPage)=0 then
			TotalPages = TotalPut \ MaxPerPage
		else
			TotalPages = TotalPut \ MaxPerPage + 1
		end if
		if CurrentPage > TotalPages then CurrentPage=TotalPages
		if CurrentPage < 1 then CurrentPage=1
		rsInfo.move (CurrentPage-1)*MaxPerPage
		SqlInfo=rsInfo.GetRows(MaxPerPage)
	else
		SqlInfo=rsInfo.GetRows(-1)
	end if
	rsInfo.close:set rsInfo=Nothing
   	dim sTemp,Linkurl,i
	dim TitleStr,Author,AuthorName,AuthorEmail,sTitleLen
    i=0:sTemp = "<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"" class="""&CssStyle&""">" & VbCrlf
	For i=0 to Ubound(SqlInfo,2)
		sTitleLen = TitleLen
		sTemp = sTemp & "<tr><td align=""left"">&nbsp;"
		if ShowProperty=True then
			if SqlInfo(18,i)=True then
				sTemp = sTemp & "<img src=""" & Cl.mainpic(19) & """ alt=""固顶"" />&nbsp;"
			elseif SqlInfo(20,i)=True then
				sTemp = sTemp & "<img src=""" & Cl.mainpic(18) & """ alt=""推荐"" />&nbsp;"
			else
				sTemp = sTemp & "<img src=""" & Cl.mainpic(17) & """ alt=""普通"" />&nbsp;"
			end if
		end if
		if ShowClassName=True and SqlInfo(1,i)<>ClassID then
			sTemp=sTemp & "[<a href=""" & Cl.WebDir & Cl.GetClassUrl(Cl.Channel_Setting(11),Cl.HtmlDir,Cl.Channel_Setting(4),SqlInfo(3,i),SqlInfo(1,i),SqlInfo(5,i),SqlInfo(4,i),Cl.Channel_Setting(10),Cl.Channel_Setting(13)) & """>" & SqlInfo(2,i) & "</a>]&nbsp;"
			sTitleLen=sTitleLen-Cl.strLength(SqlInfo(2,i))-1
		end if
		'if ShowPrefix=True and SqlInfo(7,i)<>"" then
		'	sTemp = sTemp & "<font color=blue>"&SqlInfo(7,i)&"</font>"
		'	sTitleLen=sTitleLen-Cl.strLength(SqlInfo(7,i))-2
		'end if
		if SqlInfo(25,i) and Clng(Cl.Channel_Setting(10))=1 then
			LinkUrl=Cl.WebDir & SqlInfo(26,i)
		else
			LinkUrl=Cl.WebDir & Cl.Channel_Setting(4) & "/PhotoShow.asp?PhotoID="&SqlInfo(0,i)
		end if
		sTemp = sTemp & "<a href=""" & LinkUrl & """ title=""标题：" & SqlInfo(6,i) & vbcrlf & "作者：" & SqlInfo(8,i) & vbcrlf & "更新：" & SqlInfo(16,i) & vbcrlf & "点击：" & SqlInfo(12,i) & """ target=""_blank"">"
		TitleStr=Cl.GotTopic(SqlInfo(6,i),sTitleLen)
		sTemp=sTemp & TitleStr & "</a>"
		if ShowHot=True then
		    if CDate(FormatDateTime(SqlInfo(16,i),2))=date() then
			   sTemp= sTemp & "<img src=""" & Cl.mainpic(7) & """ alt=""最新"" />"
            elseif SqlInfo(19,i)=True then
				sTemp= sTemp & "<img src=""" & Cl.mainpic(8) & """ alt=""热门"" />"
			end if
		end if
		if ShowAuthor=True or ShowHits=True or ShowDateType>0 then
			sTemp = sTemp & "</td>" & VbCrlf & "<td align=""right"">("
			if ShowAuthor=True then
				sTemp=sTemp & "<a href=""mailto:" & SqlInfo(9,i) & """>" & SqlInfo(8,i) & "</a>"
			end if
			if ShowHits=True then
				if ShowAuthor=True then
					sTemp=sTemp & ","
				end if
				sTemp=sTemp & Cl.FormatColor(SqlInfo(12,i),"#ff0033")
			end if
			if ShowDateType>0 then
				if ShowHits=True or ShowAuthor=True then
					sTemp=sTemp & ","
				end if
				if CDate(FormatDateTime(SqlInfo(16,i),2))=date() then
					sTemp = sTemp & "<font color=""red"">"
				else
					sTemp = sTemp & "<font color=""#999999"">"
				end if
		        sTemp = sTemp & Cl.Format_Time(SqlInfo(16,i),ShowDateType) & "</font>"
			end if
			sTemp = sTemp & ")"
		end if
		sTemp = sTemp & "</td></tr>" & VbCrlf
	Next
	ShowPhoto=sTemp & "</table>"
	SqlInfo=Empty
End Function

'================================================================
'过程名：ShowTopPhoto(sChannelID,sClassID,TopNum,TitleLen,ShowType,ShowHits)
'		sChannelID	----频道ID
'		sClassID	----栏目ID
'		TopNum		----下载TOP
'		TitleLen	----标题最多字符数，一个汉字=两个英文字符
'		ShowType	----- 1(本日)，2(本周),3(本月),4(累计)
'		ShowHits	------	(是否显示点击数，True为是)
'================================================================
Function ShowTopPhoto(Byval sChannelID,Byval sClassID,Byval TopNum, _
	Byval TitleLen,Byval ShowType,Byval ShowHits)
	dim sqlTop,rsTop,LinkUrl
	On Error ReSume Next
	sChannelID	= Clng(sChannelID)	: sClassID = Clng(sClassID)
	TopNum		= Clng(TopNum)		: TitleLen = Clng(TitleLen)
	ShowType	= Clng(ShowType)	: ShowHits = CBool(ShowHits)
	if Err then Err.Clear : ShowTopPhoto="ShowTopPhoto参数错误。" : Exit Function
	On Error GoTo 0
	Cl.GetChannelSetting(sChannelID)
	if TopNum>0 then
		sqlTop="select top " & TopNum & " "
	else
		sqlTop="select top 10 "
	end if
	sqlTop=sqlTop & " PhotoID,ClassID,PhotoName,Author,AuthorEmail,Editor,Keyword,Hits,DayHits,WeekHits,MonthHits,UpdateTime,PhotoPicUrl,OnTop,Elite,Passed,PhotoIntro,PhotoLevel,PhotoPoint,Stars,IsHtml,HtmlFileUrl from Cl_Photo where Deleted=False and Passed=True and ChannelID="&sChannelID&" "
	if sClassID>0 then
		Dim tClass
		Set tClass=Cl.Execute("select ClassID,Child,ParentPath,arrChildID from Cl_Class where ChannelID="&sChannelID&" and ClassID=" & sClassID)
		if not(tClass.bof and tClass.eof) then
			if tClass(1)>0 then
				sqlTop=sqlTop & " and ClassID in (" & tClass(3) & ")"
			else
				sqlTop=sqlTop & " and ClassID=" & sClassID
			end if
		else
			sqlTop=sqlTop & " and ClassID=" & sClassID
		end if
		Set tClass=Nothing
	end if
	Select Case ShowType
	Case 1
		sqlTop=sqlTop & " And datediff('D',LastHitTime,now())<=0 order by DayHits desc,PhotoID desc"
	Case 2
		sqlTop=sqlTop & " And datediff('ww',LastHitTime,now())<=0 order by WeekHits desc,PhotoID desc"
	Case 3
		sqlTop=sqlTop & " And datediff('m',LastHitTime,now())<=0 order by MonthHits desc,PhotoID desc"
	Case Else
		sqlTop=sqlTop & " order by Hits desc,PhotoID desc"
	end Select
	Set rsTop= Cl.Execute(sqlTop)
	if rsTop.bof and rsTop.eof then 
		ShowTopPhoto = "<li>没有"&Cl.Channel_Setting(2)&"</li>"
		rsTop.Close:Set rsTop=Nothing:Exit Function
	End if
	Dim i,sTemp
	i=1:sTemp = ""
	sqlTop=rsTop.GetRows(-1)
	rsTop.Close:Set rsTop=Nothing
	For i=0 to Ubound(sqlTop,2)
		if sqlTop(20,i)=True and Clng(Cl.Channel_Setting(10))=1 then
			LinkUrl=Cl.WebDir & sqlTop(21,i)
		else
			LinkUrl=Cl.WebDir & Cl.Channel_Setting(4) & "/PhotoShow.asp?PhotoID="&sqlTop(0,i)
		end if
		sTemp = sTemp & "<li><a href=""" & LinkUrl & """ title=""名称：" & sqlTop(2,i) & vbcrlf & "作者：" & sqlTop(3,i) & vbcrlf & "更新：" & sqlTop(11,i) & vbcrlf & "查看：" & sqlTop(7,i) & """ target=""_blank"">" & Cl.gotTopic(sqlTop(2,i),TitleLen) & "</a>"
		if ShowHits=True then
			sTemp=sTemp & "(<font color=red>" & sqlTop(7,i) & "</font>)"
		end if
		sTemp=sTemp & "</li><br />"
    Next
	ShowTopPhoto=sTemp
	sqlTop=Empty
End Function


'=======================================================================
'显示相关文章
'ShowCorrelativePhoto(sChannelID,TopNum,TitleLen,ShowHits)
'	sChannelID
'	TopNum		------	(文章数量)
'	TitleLen	------	(标题字符数)
'	ShowHits	------	(是否显示点击数，True为是)
'=======================================================================
Function ShowCorrelativePhoto(Byval sChannelID,Byval TopNum,Byval TitleLen,Byval ShowHits)
	dim rsC,SQL,sTemp
	sChannelID=Cl.ChkClng(sChannelID):ShowHits=Cl.ChkCBool(ShowHits)
	TopNum=Cl.ChkClng(TopNum):TitleLen=Cl.ChkClng(TitleLen)
	dim strKey,arrKey,i,LinkUrl
	if TopNum>0 then
		SQL="select top " & TopNum
	else	
		SQL="Select Top 5 "
	end if
	strKey=rs("Keyword")
	if instr(strkey,"|")>1 then
		arrKey=split(strKey,"|")
		strKey="((Keyword like '%" & arrKey(0) & "%')"
		for i=1 to ubound(arrKey)
			strKey=strKey & " or (Keyword like '%" & arrKey(i) & "%')"
		next
		strKey=strKey & ")"
	else
		strKey="(Keyword like '%" & strKey & "%')"
	end if

	SQL=SQL & " PhotoID,PhotoName,Author,Keyword,UpdateTime,Editor,Hits,PhotoSize,PhotoLevel,PhotoPoint,IsHtml,HtmlFileUrl from Cl_Photo Where Deleted=False and Passed=True and " & strKey & " and PhotoID<>" & PhotoID & " and ChannelID="&sChannelID&" Order by UpdateTime desc, PhotoID desc"
	Set rsC= Cl.Execute(SQL)
	if TitleLen<0 or TitleLen>255 then TitleLen=50
	if rsC.bof and rsC.Eof then
		sTemp = "没有相关图片"
	else
		Cl.GetChannelSetting(sChannelID)
	 	do while not rsC.eof
			if rsC("IsHtml")=True and Clng(Cl.Channel_Setting(10))=1 then
				LinkUrl=Cl.WebDir & rsC("HtmlFileUrl")
			else
				LinkUrl=Cl.WebDir & Cl.Channel_Setting(4) & "/PhotoShow.asp?PhotoID="&rsC("Photoid")
			end if
			sTemp = sTemp & "<li><a href=""" & LinkUrl & """ title=""图片名称：" & rsC("PhotoName") & vbcrlf & "图片大小：" & rsC("PhotoSize") & "K" & vbcrlf & "作    者：" & rsC("Author") & vbcrlf & "更新时间：" & rsC("UpdateTime") & vbcrlf & "查看次数：" & rsC("Hits") & """ target=""_blank"">" & Cl.gotTopic(rsC("PhotoName"),TitleLen)
			if ShowHits=True then
			sTemp = sTemp & "[<font color=red>" & rsC("hits") & "</font>]"
			end if
			sTemp = sTemp & "</li><br />"
			rsC.movenext
		loop
	end if
	rsC.Close : set rsC=Nothing
	ShowCorrelativePhoto=sTemp
End Function

Public Sub ChkPhotoLevel()
	if Not Cl.TrueBrowsePurview then
		Response.write Template.Strings(2)
		Response.end
	end if
	if Cl.ChkUserLevel(rs("PhotoLevel"),5) and rs("PhotoPoint")=0 and rs("PhotoMoney")=0 then Exit Sub
	If Cl.UserID=0 or Cl.UserLevel=5 then
		Response.write Template.Strings(3)
		Response.end
	End if
	if Not Cl.ChkUserLevel(rs("PhotoLevel"),Cl.UserLevel) then
		Response.write Replace(Template.Strings(4),"{%level%}",Cl.GetUserGroupName(rs("PhotoLevel")))
		Response.end
	End if
	Dim rsL,SQLL,IsPay
	SQLL="Select Top 1 ID,ConsumePoint,ConsumeMoney,ConsumeNums,ConsumeLog,ConsumeTime From Cl_ConsumeLog Where ChannelID="&ChannelID&" and InfoID="&PhotoID&" and UserID="&Cl.UserID&" Order By ID Desc"
	Set rsL=Server.CreateObject("adodb.recordset")
	OpenConn_L : rsL.Open SQLL,Conn_L,1,3
	if rsL.Bof and rsL.Eof then
		IsPay=False
	else
		IsPay=True
		'if *** then IsPay=False
		rsL("ConsumeNums")=rsL("ConsumeNums")+1
		rsL.Update
	end if
	rsL.Close : Set rsL=Nothing
	Dim sBackMoney,sBackPoint
	Select Case Cint(Cl.User_Info(24))
	Case 1
		if IsPay=False and (rs("PhotoPoint")>0 or rs("PhotoMoney")>0) then
			if Clng(Cl.User_Info(22))<rs("PhotoPoint") or Clng(Cl.User_Info(23))<rs("PhotoMoney") then
				ErrMsg=Replace(Template.Strings(7),"{%photopoint%}",rs("PhotoPoint"))
				ErrMsg=Replace(ErrMsg,"{%userpoint%}",Cl.User_Info(22))
				ErrMsg=Replace(ErrMsg,"{%photomoney%}",rs("PhotoMoney"))
				ErrMsg=Replace(ErrMsg,"{%usermoney%}",Cl.User_Info(23))
				response.write Cl.ReplaceItem(ErrMsg)
				response.end
			End if
			if Lcase(trim(request("Pay")))="yes" then
				Cl.Execute_U "update " & Db.UserTable & " set " & Db.UserPoint & "=" & Db.UserPoint & "-" & rs("PhotoPoint") & "," & Db.UserMoney & "=" & Db.UserMoney & "-" & rs("PhotoMoney") & " where " & Db.UserID & "=" & Clng(Cl.UserID) & ""
				Cl.Execute_L("Insert Into Cl_ConsumeLog (ChannelID,InfoID,Title,Url,UserID,UserName,ConsumePoint,ConsumeMoney,ConsumeNums,ConsumeTime) values ("&ChannelID&","&PhotoID&",'"&InfoTitle&"','"&Request.ServerVariables("PATH_INFO")&"',"&Cl.User_Info(4)&",'"&Cl.User_Info(5)&"',"&rs("PhotoPoint")&","&rs("PhotoMoney")&",0,'"&Now&"')")
				Cl.GetCacheUserInfo
				sBackMoney=rs("BackMoney") + Clng(rs("PhotoMoney")*rs("BackMoneyRate")/100)
				sBackPoint=rs("BackPoint") + Clng(rs("PhotoPoint")*rs("BackPointRate")/100)
				if sBackMoney>0 or sBackPoint>0 then
				Cl.Execute_U "update " & Db.UserTable & " set " & Db.UserPoint & "=" & Db.UserPoint & "+" & sBackPoint & "," & Db.UserMoney & "=" & Db.UserMoney & "+" & sBackMoney & " where " & Db.UserName & "='" & rs("Editor") & "'"
				end if
			else
				ErrMsg=Replace(Template.Strings(8),"{%photopoint%}",rs("PhotoPoint"))
				ErrMsg=Replace(ErrMsg,"{%userpoint%}",Cl.User_Info(22))
				ErrMsg=Replace(ErrMsg,"{%photomoney%}",rs("PhotoMoney"))
				ErrMsg=Replace(ErrMsg,"{%usermoney%}",Cl.User_Info(23))
				Response.write Replace(ErrMsg,"{%photourl%}","PhotoView.asp?Pay=yes&UrlID="&UrlID&"&PhotoID="&PhotoID&"")
				Response.end
			end if
		end if
	Case 2
		if Clng(Cl.User_Info(40))<=0 then
			response.write Template.Strings(7)
			response.end
		elseif IsPay=False and Rs("PhotoMoney")>0 then
			if Clng(Cl.User_Info(23))<rs("PhotoMoney") then '2
				ErrMsg=Replace(Template.Strings(7),"{%photopoint%}",0)
				ErrMsg=Replace(ErrMsg,"{%userpoint%}",0)
				ErrMsg=Replace(ErrMsg,"{%photomoney%}",rs("PhotoMoney"))
				ErrMsg=Replace(ErrMsg,"{%usermoney%}",Cl.User_Info(23))
				response.write Cl.ReplaceItem(ErrMsg)
				response.end
			else '2
				If lcase(Trim(request("Pay")))="yes" then
					Cl.Execute_U "update " & Db.UserTable & " set " & Db.UserMoney & "=" & Db.UserMoney & "-" & rs("PhotoMoney") & " where " & Db.UserID & "=" & Clng(Cl.UserID) & ""
					Cl.Execute_L("Insert Into Cl_ConsumeLog (ChannelID,InfoID,Title,Url,UserID,UserName,ConsumePoint,ConsumeMoney,ConsumeNums,ConsumeTime) values ("&ChannelID&","&PhotoID&",'"&InfoTitle&"','"&Request.ServerVariables("PATH_INFO")&"',"&Cl.User_Info(4)&",'"&Cl.User_Info(5)&"',0,"&rs("SoftMoney")&",0,'"&Now&"')")
					Cl.GetCacheUserInfo
					sBackMoney=rs("BackMoney") + Clng(rs("PhotoMoney")*rs("BackMoneyRate")/100)
					sBackPoint=rs("BackPoint") + Clng(rs("PhotoPoint")*rs("BackPointRate")/100)
					if sBackMoney>0 or sBackPoint>0 then
					Cl.Execute_U "update " & Db.UserTable & " set " & Db.UserPoint & "=" & Db.UserPoint & "+" & sBackPoint & "," & Db.UserMoney & "=" & Db.UserMoney & "+" & sBackMoney & " where " & Db.UserName & "='" & rs("Editor") & "'"
					end if
				Else
					ErrMsg=Replace(Template.Strings(8),"{%photopoint%}",0)
					ErrMsg=Replace(ErrMsg,"{%userpoint%}",0)
					ErrMsg=Replace(ErrMsg,"{%photomoney%}",rs("PhotoMoney"))
					ErrMsg=Replace(ErrMsg,"{%usermoney%}",Cl.User_Info(23))
					Response.write Replace(ErrMsg,"{%photourl%}","PhotoView.asp?Pay=yes&UrlID="&UrlID&"&PhotoID="&PhotoID&"")
					Response.end
				End if
			End if '2
		End if
	Case Else
		response.write Template.Strings(7)
		response.end
	End Select
End Sub
%>