<%
sub Dream_Fromlist(ClassID,from,strTpl,zishu)
	str_sql=""
	str_order=""
	if from="hot" then
	str_sql=" and Dream_Hot=true"
	str_order=" Dream_HotTime desc,id desc"
	elseif from="new" then
	str_sql=" and Dream_New=true"
	str_order=" Dream_NewTime desc,id desc"
	elseif from="Choice" then
	str_sql=" and Dream_Choice=true"
	str_order="Dream_OrderID desc, Dream_NewTime desc,id desc"
	else
	str_sql=""
	str_order=" Dream_Hits desc,id desc"
	end if
	set rs=server.createobject("adodb.recordset")
	if ClassID=0 or ClassID="" then
	sql="select top "&strTpl&" * from Dream_Menpiao where Dream_IsOK=true and id<>0 "&str_sql&" order by "&str_order
	else
	sql="select top "&strTpl&" * from Dream_Menpiao where Dream_IsOK=true and id<>0 "&str_sql&" and Dream_Theme in (select id from Dream_Theme where Dream_Classid="&ClassID&" or id="&ClassID&") order by "&str_order
	end if
	rs.open sql,conn,1,1
	prolist=""
	k=1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	if rs("Dream_DownUrl")<>"" then
	Dream_DownUrl=rs("Dream_DownUrl")
	target="_blank"
	else
	Dream_DownUrl="view.asp?cid="&rs("Dream_Theme")&"&id="&rs("id")
	target="_self"
	end if
	Dream_Title=gotTopic(ClearHtml(rs("Dream_Title"),0),zishu*2)
	prolist=prolist&"<li class=""item""><a href="""&Dream_DownUrl&""" target="""&target&""" title="""&rs("Dream_Title")&"""><img src="""&rs("Dream_DefaultPicUrl")&""" /><h3>"&Dream_Title&"</h3></a></li>"
	if k mod 2 =0 then
	prolist=prolist&"</ul><ul>"
	end if
	k=k+1	
	rs.movenext
	loop
	response.Write prolist
	else
	response.write "<center>此栏目暂无任何新增信息</center>"
	end if
	rs.close
	set rs=nothing	
End sub

function Review(Tid)	
	sql="select COUNT(Dream_Grade) as Grade_COUNT from Dream_Review where Dream_Look=true and Dream_ViewID="&Tid
	set rs=conn.execute(sql)
	if rs("Grade_COUNT")>0 then
	set rs=server.createobject("adodb.recordset")
	sql="select AVG(Dream_Grade) as Grade from Dream_Review where Dream_ViewID="&Tid
	rs.open sql,conn,1,1
	Review=FormatNumber(rs("Grade"),1,-1)	
	rs.close
	set rs=nothing
	else
	Review=0
	end if
end function

function userrz(userid)
	userrzstr="no"
	set rsuser=server.CreateObject("adodb.recordset")
	sqluser="select top 1 * from Dream_User where Dream_UserName='"&userid&"' order by id desc"
	rsuser.open sqluser,Conn,1,1	
	if not(rsuser.eof and rsuser.bof) then
	if rsuser("Dream_IdentityOK")<>"" and rsuser("Dream_IdentityOK")="通过验证" then
	userrzstr="yes"
	end if
	end if
	rsuser.close
	set rsuser=nothing
	userrz=userrzstr
end function

function leftmenu(cid)
	set rs=server.CreateObject("adodb.recordset")
	if cid=0 then
	sql="select * from Dream_Theme where Dream_ClassID=0 order by Dream_zid asc, id asc"
	else
	sql="select * from Dream_Theme where Dream_ClassID="&cid&" order by Dream_zid asc, id asc"
	end if
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	i=1
	do while not rs.eof
	if rs("Dream_DefaultPicUrl")<>"" then
	Dream_DefaultPicUrl=rs("Dream_DefaultPicUrl")
	else
	Dream_DefaultPicUrl="images/nopic.png"
	end if
	if rs("Dream_ClassID")=0 then
	url="page.asp?cid="&rs("id")
	else
	url="page.asp?cid="&rs("Dream_ClassID")&"&sid="&rs("id")
	end if
	leftmenu=leftmenu&"<li class=""c"&i&"""><a href="""&url&"""><img src=""../"&Dream_DefaultPicUrl&""" alt="""&rs("Dream_Names")&"""></cite><span>"&rs("Dream_Names")&"</span></a></li>"	
	i=i+1
	if i>8 then i=1
	rs.movenext
	loop
	
	end if
	rs.close
	set rs=nothing
	leftmenu=leftmenu
end function

function pagemenu(mkid,cid)
	set rs=server.CreateObject("adodb.recordset")
	if cid=0 then
	sql="select * from Dream_Class where Dream_ModularID="&mkid&" order by Dream_zid asc, id desc"
	else
	sql="select * from Dream_Class where Dream_ModularID="&mkid&" and Dream_ClassID="&cid&" order by Dream_zid asc, id desc"
	end if
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	i=1
	do while not rs.eof
	if rs("Dream_WebUrl")<>"" then
	url=rs("Dream_WebUrl")
	target="_blank"
	else
	url="aboutlist.asp?cid="&rs("id")
	target="_self"
	end if	
	pagemenu=pagemenu&"<li class=""c"&i&"""><a href="""&url&""" target="""&target&""">"&rs("Dream_Names")&"</a></li>"	
	i=i+1
	if i>8 then i=1
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
	pagemenu=pagemenu
end function

sub DreamNewsList(classid,areaid,pagenum,page,zishu,otypeid,keys)
	Set rs=Server.CreateObject("ADODB.RecordSet")
	if keys<>"" then
	sql="select * from Dream_Menpiao where Dream_IsOK=true and Dream_Title like '%"&keys&"%' order by id desc"
	else
	select case otypeid
	case 1
	otypesql=" order by id desc"
	case 2
	otypesql=" order by Dream_UpdateTime desc,id desc"
	case 3
	otypesql=" order by int(Dream_ProID) desc,id desc"
	case 4
	otypesql=" order by CCur(Dream_Price) asc,id desc"
	case 5
	otypesql=" order by CCur(Dream_Price) desc,id desc"
	case else
	otypesql=" order by id desc"
	end select
	
	if classid=0 and areaid=0 then
	sql="select * from Dream_Menpiao"&otypesql
	elseif classid<>0 and areaid=0 then 
	sql="select * from Dream_Menpiao where Dream_Theme in (select id from Dream_Theme where id="&classid&" or Dream_ClassID="&classid&")"&otypesql
	elseif classid=0 and areaid<>0 then 
	sql="select * from Dream_Menpiao where Dream_Area in (select id from Dream_Area where id="&areaid&" or Dream_ClassID="&areaid&")"&otypesql
	elseif classid<>0 and areaid<>0 then 
	sql="select * from Dream_Menpiao where Dream_Theme in (select id from Dream_Theme where id="&classid&" or Dream_ClassID="&classid&") and Dream_Area in (select id from Dream_Area where id="&areaid&" or Dream_ClassID="&areaid&")"&otypesql
	end if
	end if
	rs.open sql,conn,1,1
	if not(rs.eof and rs.bof) then
	rs.PageSize=pagenum
	if page=0 then page=1 
	pages=rs.pagecount
	if page > pages then page=pages
	rs.AbsolutePage=page
	prolist=""
	for j=1 to rs.PageSize
	if rs("Dream_DownUrl")<>"" then
	Dream_DownUrl=rs("Dream_DownUrl")
	target="_blank"
	else
	Dream_DownUrl="view.asp?cid="&rs("Dream_Theme")&"&id="&rs("id")
	target="_self"
	end if
	
	if rs("Dream_Follow")<>"" then
	Dream_Follow="<span class=""gz""><a href="""&rs("Dream_DownUrl")&""" target=""_blank"">我要关注</a></span>"
	else
	Dream_Follow=""
	end if
	
	Dream_Content=gotTopic(ClearHtml(rs("Dream_Content"),0),zishu*2)
	prolist=prolist&"<li class=""item""> <a href="""&Dream_DownUrl&""" target="""&target&"""><div class=""pic""><img src=""../"&rs("Dream_DefaultPicUrl")&""" /></div><div class=""nr""><p class=""title"">"&replace(rs("Dream_Title"),keys,"<i>"&keys&"</i>")&"</p><p class=""desc"">"&replace(Dream_Content,keys,"<i>"&keys&"</i>")&"</p><span class=""price"">原价"&rs("Dream_Currency_Symbol")&rs("Dream_Price")&"&nbsp;/&nbsp;团购价"&rs("Dream_Currency_Symbol2")&rs("Dream_Price2")&"</span></div></a><div class=""item_an""><span class=""ljdc""><a href=""enter.asp?id="&rs("id")&""">立即订餐</a></span>"&Dream_Follow&"<span class=""sales"">"&rs("Dream_ProID")&"人购买</span></div></li>"
	rs.movenext
	if rs.eof then exit for
	next
	response.Write prolist
	else
	response.write "<div class=""nonews"">此栏目暂无任何新增信息</div>"
	end if
	session("pagecount")=rs.pagecount
	session("recordcount")=rs.recordcount
	session("PageSize")=rs.PageSize
	rs.close
	set rs=nothing
end sub

sub centpage(namess,Page)
	if Page<2 then      
		response.write "首页 上一页&nbsp;"
	else
		response.write "<a href=?"&url&"&page=1>首页</a>&nbsp;"
		response.write "<a href=?"&url&"&page=" & Page-1 & ">上一页</a>&nbsp;"
	end if
		if session("pagecount")-page<1 then
		response.write "下一页 尾页"
	else
		response.write "<a href=?"&url&"&page=" & (page+1) & ">"
		response.write "下一页</a> <a href=?"&url&"&page="&session("pagecount")&">尾页</a>"
	end if
		response.write "&nbsp;页次：<strong><span class=red>"&Page&"</span>/"&session("pagecount")&"</strong>页 "
end sub

function city(AreaID)
	set rsCity=server.CreateObject("adodb.recordset")
	sqlCity="select * from Dream_Area where id="&AreaID
	rsCity.open sqlCity,Conn,1,1
	if not(rsCity.eof and rsCity.bof) then		
	city="["&rsCity("Dream_Names")&"]"
	end if
	rsCity.close
	set rsCity=nothing
end function

function Banner(cid)
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Dream_Articles where Dream_Elite=true and Dream_ClassID in (select id from Dream_Class where Dream_Classid="&cid&" or id="&cid&") order by Dream_EliteTime desc, id asc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	if rs("Dream_DownUrl")<>"" then
	url=rs("Dream_DownUrl")
	target="_blank"
	else
	url="view.asp?id="&rs("id")
	target="_self"
	end if	
	Banner=Banner&"<div class=""swiper-slide""><a href="""&url&""" target="""&target&"""><img src="""&rs("Dream_DefaultPicUrl")&""" /></a></div>"	
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
	Banner=Banner
end function

'*************************************************
'函数名：gotTopic
'作  用：截字符串，汉字一个算两个字符，英文算一个字符
'参  数：str   ----原字符串
'       strlen ----截取长度
'返回值：截取后的字符串
'*************************************************
function gotTopic(str,strlen)
	if str="" then
		gotTopic=""
		exit function
	end if
	dim l,t,c, i
	'str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
	l=len(str)
	t=0
	for i=1 to l
		c=Abs(Asc(Mid(str,i,1)))
		if c>255 then
			t=t+2
		else
			t=t+1
		end if
		if t>=strlen then
			gotTopic=left(str,i) & "…"
			exit for
		else
			gotTopic=str
		end if
	next
	gotTopic=gotTopic
	'gotTopic=replace(replace(replace(replace(gotTopic," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function


'***************************************************
'函数名：IsObjInstalled
'作  用：检查组件是否已经安装
'参  数：strClassString ----组件名
'返回值：True  ----已经安装
'       False ----没有安装
'***************************************************
Function IsObjInstalled(strClassString)
	On Error Resume Next
	IsObjInstalled = False
	Err = 0
	Dim xTestObj
	Set xTestObj = Server.CreateObject(strClassString)
	If 0 = Err Then IsObjInstalled = True
	Set xTestObj = Nothing
	Err = 0
End Function

'**************************************************
'函数名：strLength
'作  用：求字符串长度。汉字算两个字符，英文算一个字符。
'参  数：str  ----要求长度的字符串
'返回值：字符串长度
'**************************************************
function strLength(str)
	ON ERROR RESUME NEXT
	dim WINNT_CHINESE
	WINNT_CHINESE    = (len("中国")=2)
	if WINNT_CHINESE then
        dim l,t,c
        dim i
        l=len(str)
        t=l
        for i=1 to l
        	c=asc(mid(str,i,1))
            if c<0 then c=c+65536
            if c>255 then
                t=t+1
            end if
        next
        strLength=t
    else 
        strLength=len(str)
    end if
    if err.number<>0 then err.clear
end function



Function HTMLEncode(fString)
fString = replace(fString,">",">")
fString = replace(fString,"<","<")
fString = Replace(fString,CHR(32)," ")
fString = Replace(fString,CHR(13),"")
fString = Replace(fString,CHR(10) & CHR(10),"<br>")
fString = Replace(fString,CHR(10),"<br>")
HTMLEncode = fString
end function

Function ReHTMLEncode(fString)
fString = replace(fString,">",">")
fString = replace(fString,"<","<")
fString = Replace(fString," ",CHR(32))
fString = Replace(fString,"",CHR(13))
'fString = Replace(fString,"<br>",CHR(10) & CHR(10))
fString = Replace(fString,"<br>",CHR(10))
ReHTMLEncode = fString
end function

Function ClearHtml(Content,style)

if style<>1 then '1表示不过滤<p></p>标签
Content=Zxj_ReplaceHtml("</?p[^>]*>","",Content)
end if
Content=Zxj_ReplaceHtml("&#[^>]*;", "", Content) 
Content=Zxj_ReplaceHtml("</?marquee[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?object[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?param[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?embed[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?table[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml(" ","",Content)
Content=Zxj_ReplaceHtml("　","",Content)
Content=Zxj_ReplaceHtml("&nbsp;","",Content)
Content=Zxj_ReplaceHtml("</?tr[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?st1[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?th[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?a[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?img[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?tbody[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?li[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?span[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?div[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?th[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?td[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?script[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content) 
Content=Zxj_ReplaceHtml("on(mouse|exit|error|click|key)", "", Content) 
Content=Zxj_ReplaceHtml("<\\?xml[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("<\/?[a-z]+:[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?font[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?b[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?u[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?i[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?h[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?strong[^>]*>","",Content) 
ClearHtml=Content 
End Function 

Function Zxj_ReplaceHtml(patrn, strng,content) 
IF IsNull(content) Then 
content="" 
End IF 
Set regEx = New RegExp ' 建立正则表达式。 
regEx.Pattern = patrn ' 设置模式。 
regEx.IgnoreCase = true ' 设置忽略字符大小写。 
regEx.Global = True ' 设置全局可用性。 
Zxj_ReplaceHtml=regEx.Replace(content,strng) ' 执行正则匹配 
End Function

Function GetAllImgSrc(ByVal strHtml) 
   Dim rtnStr,Reg,Matches,Match 
   rtnStr = "" 
   IF Not(IsNull(strHtml) Or Len(strHtml)=0) Then 
       Set Reg = New RegExp 
       Reg.Pattern = "<img[^>]+src=""([^"">]+)""[^>]*>" 
       Reg.Ignorecase = True 
       Reg.Global = True 
       Set Matches = Reg.Execute(strHtml) 
       IF Matches.Count > 0 Then 
           For Each Match In Matches 
               'IF Left(Match.SubMatches(0),7) <> "http://" Then 
                   ' 以下返回方式，可以根据你自己的需要，进行修改。 
                   rtnStr = rtnStr & "<div class=""swiper-slide""><img src=""" & Match.SubMatches(0) & """></div>" 
               'End IF 
           Next 
       End IF 
   End IF 
   GetAllImgSrc = rtnStr 
   Set Matches = Nothing 
   Set Regs = Nothing 
End Function

Function GetAllImgSrc_Info(ByVal strHtml) 
   Dim rtnStr,Reg,Matches,Match 
   rtnStr = "" 
   IF Not(IsNull(strHtml) Or Len(strHtml)=0) Then 
       Set Reg = New RegExp 
       Reg.Pattern = "<img[^>]+src=""([^"">]+)""[^>]*>" 
       Reg.Ignorecase = True 
       Reg.Global = True 
       Set Matches = Reg.Execute(strHtml) 
       IF Matches.Count > 0 Then 
           For Each Match In Matches 
              rtnStr = rtnStr & Match.SubMatches(0)
           Next 
       End IF 
   End IF 
   GetAllImgSrc_Info = rtnStr 
   Set Matches = Nothing 
   Set Regs = Nothing 
End Function
%>

