<%
Dim G_P_Show
G_P_Show=G_P_Show& "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"& vbcrlf
G_P_Show=G_P_Show& "<html xmlns=""http://www.w3.org/1999/xhtml"">" & vbcrlf
G_P_Show=G_P_Show& "<head>" & vbcrlf
G_P_Show=G_P_Show& "<meta http-equiv=""content-type"" content=""text/html; charset=gb2312"">"& vbcrlf
G_P_Show=G_P_Show& "<meta name=""generator"" content=""oblog"">"& vbcrlf
G_P_Show=G_P_Show& "<meta name=""keywords"" content="""&oblog.cacheConfig(9)&""">"& vbcrlf
G_P_Show=G_P_Show& "<link rel=""alternate"" href=""rss2.asp"" type=""application/rss+xml"" title=""rss"" >"& vbcrlf
G_P_Show=G_P_Show& "<title>"&oblog.cacheConfig(2)&"</title>"& vbcrlf
G_P_Show=G_P_Show& "<link href=""OblogStyle/OblogsysDefault4.css"" rel=""stylesheet"" type=""text/css"" /> "& vbcrlf
G_P_Show=G_P_Show& "<script src=""inc/main.js""></script>"& vbcrlf
G_P_Show=G_P_Show& "<script>function chkdiv(divid){var chkid=document.getElementById(divid);if(chkid != null){return true; }else {return false; }}</script>"& vbcrlf
G_P_Show=G_P_Show& "{OB_STYLE}"& vbcrlf
G_P_Show=G_P_Show& "</head>"& vbcrlf
G_P_Show=G_P_Show& "<body>"& vbcrlf

Function show_userlogin(n)
	if n=0 then
		show_userlogin = "<div id=""ob_login""></div>"&"<script src='login.asp?action=showindexlogin'></script>"
	else
		show_userlogin = "<div id=""ob_login""></div>"&"<script src='login.asp?action=showindexlogin&n=1'></script><script src=""inc/main.js""></script>"
	end if
End Function

Sub indexshow()

	If InStr(G_P_Show, "$show_sitename$") > 0 Then
		G_P_Show = Replace(G_P_Show, "$show_sitename$", oblog.cacheconfig(1))
	End If

	If InStr(G_P_Show, "$show_placard$") > 0 Then
		G_P_Show = Replace(G_P_Show, "$show_placard$", show_placard())
	End If

	If InStr(G_P_Show, "$show_friends$") > 0 Then
	G_P_Show = Replace(G_P_Show, "$show_friends$", show_friends())
	End If

	If InStr(G_P_Show, "$show_count$") > 0 Then
		G_P_Show = Replace(G_P_Show, "$show_count$", show_count())
	End If

	If InStr(G_P_Show, "$show_userlogin$") > 0 Then
		G_P_Show = Replace(G_P_Show, "$show_userlogin$", show_userlogin(0))
	End If

	If InStr(G_P_Show, "$show_userlogin_l$") > 0 Then
		G_P_Show = Replace(G_P_Show, "$show_userlogin_l$", show_userlogin(1))
	End If

	If InStr(G_P_Show, "$show_xml$") > 0 Then
		G_P_Show = Replace(G_P_Show, "$show_xml$", show_sysxml())
	End If

	If InStr(G_P_Show, "$show_blogstar$") > 0 Then
		G_P_Show = Replace(G_P_Show, "$show_blogstar$", show_blogstar())
	End If

	If InStr(G_P_Show, "$show_cloudtags$") > 0 Then
		G_P_Show = Replace(G_P_Show, "$show_cloudtags$", Tags_SystemTags("1"))
	End If

	Call runsub("$show_newblogger")
	Call runsub("$show_comment")
	Call runsub("$show_subject")
	Call runsub("$show_blogupdate")
	Call runsub("$show_bestblog")
	Call runsub("$show_bloger")
	Call runsub("$show_class")
	Call runsub("$show_log")
	Call runsub("$show_userlog")
	Call runsub("$show_search")
	Call runsub("$show_cityblogger")
	Call runsub("$show_newphoto")
	Call runsub("$show_blogstar2")
	Call runsub("$show_teams")
	Call runsub("$show_posts")
	Call runsub("$show_hotblog")
	Call runsub("$show_hottag")
	Call runsub("$show_treeclass")
	Call runsub("$show_bl")
End Sub

Sub sysshow()
	if Application(oblog.cache_name&"list_update")=false and application(oblog.cache_name&"list")<>"" then
		G_P_Show=application(oblog.cache_name&"list")
	Else
		Dim rstmp,sContent,sStyle
		Set rstmp = oblog.execute("select skinshowlog from oblog_sysskin where isdefault=1")
		sContent=rstmp(0)
		sStyle=OB_PickUpCss(sContent)
		G_P_Show=Replace(G_P_Show,"{OB_STYLE}",sStyle)
		'Response.Write sStyle
		'Response.Write sContent
		G_P_Show=G_P_Show&sContent
		Set rstmp = Nothing
		'副模板取消城市选项
		G_P_Show=Replace(G_P_Show,"show_cityblogger(0)$","")
		G_P_Show=Replace(G_P_Show,"show_cityblogger(1)$","")
		Call indexshow
		Application.Lock
		application(oblog.cache_name&"list_update")=false
		application(oblog.cache_name&"list")=G_P_Show
		Application.unLock
	End If
End Sub

Sub runsub(label)
	On Error Resume Next
	Dim tmp1, tmp2, i
	Dim tmpstr, para
	tmp2 = 1
	While InStr(tmp2, G_P_Show, label) > 0
		tmp1 = InStr(tmp2, G_P_Show, label)
		tmp2 = InStr(tmp1 + 1, G_P_Show, "$")
		tmpstr = Mid(G_P_Show, tmp1, tmp2 - tmp1)
		tmpstr = Replace(tmpstr, "(", "")
		tmpstr = Replace(tmpstr, ")", "")
		tmpstr = Trim(Replace(tmpstr, label, ""))
		para = Split(tmpstr, ",")
		Select Case label
		Case "$show_log"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_log(para(0),para(1),para(2),para(3),para(4),para(5),para(6),para(7),para(8)))
			If Err Then
				Response.Write "<br/>$show_log$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_userlog"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_userlog(para(0),para(1),para(2),para(3),para(4),para(5)))
			If Err Then
				Response.Write Err.Description
				Response.Write "<br/>$show_userlog$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_comment"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_comment(para(0),para(1)))
			If Err Then
				Response.Write "<br/>$show_comment$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_subject"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_subject(para(0)))
			If Err Then
				Response.Write "<br/>$show_subject$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_blogupdate"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_blogupdate(para(0)))
			If Err Then
				Response.Write "<br/>$show_blogupdate$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_newblogger"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_newblogger(para(0)))
			If Err Then
				Response.Write "<br/>$show_newblogger$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_bestblog"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_bestblog(para(0)))
			If Err Then
				Response.Write "<br/>$show_bestblog$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_bloger"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_bloger(para(0)))
			If Err Then
				Response.Write "<br/>$show_bloger$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_class"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_class(para(0)))
			If Err Then
				Response.Write "<br/>$show_class$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_search"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_search(para(0)))
			If Err Then
				Response.Write "<br/>$show_search$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_cityblogger"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_cityblogger(para(0)))
			If Err Then
				Response.Write "<br/>$show_cityblogger$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_newphoto"
			G_P_Show=replace(G_P_Show,label&"("&tmpstr&")$",show_newphoto(para(0),para(1),para(2),para(3)))
			If Err Then
				Response.Write "<br/>$show_newphoto$标签有错误，请检查参数"
				Response.End()
			End If
		Case "$show_blogstar2"
			G_P_Show=Replace(G_P_Show,label&"("&tmpstr&")$",show_blogstar2(para(0),para(1),para(2),para(3)))
			If Err Then
				Response.Write "<br/>$show_blogstar2$标签有错误，请检查参数"
				Response.End()
			End If
		 Case "$show_hottag"
			G_P_Show=Replace(G_P_Show,label&"("&tmpstr&")$",GetHotTags(para(0),para(1),para(2),para(3)))
		Case "$show_treeclass"
			G_P_Show=Replace(G_P_Show,label&"("&tmpstr&")$",TreeClass(para(0)))
			If Err Then
				Response.Write "<br/>$show_treeclass$标签有错误，请检查参数"
				Response.Write Err.Description
				Response.End()
			End If
		Case "$show_teams"
			G_P_Show=Replace(G_P_Show,label&"("&tmpstr&")$",GetTeams(para(0),para(1),para(2),para(3),para(4),para(5)))
			If Err Then
				Response.Write "<br/>$show_teams$标签有错误，请检查参数"
				Response.Write Err.Description
				Response.End()
			End If
		Case "$show_posts"
			G_P_Show=Replace(G_P_Show,label&"("&tmpstr&")$",GetPosts(para(0),para(1),para(2),para(3),para(4)))
			If Err Then
				Response.Write "<br/>$show_posts$标签有错误，请检查参数"
				Response.Write Err.Description
				Response.End()
			End If
		Case "$show_hotblog"
			G_P_Show=Replace(G_P_Show,label&"("&tmpstr&")$",GetHotUsers(para(0),para(1)))
			If Err Then
				Response.Write "<br/>$show_hotblog$标签有错误，请检查参数"
				Response.Write Err.Description
				Response.End()
			End If
		Case "$show_bl"
			G_P_Show=Replace(G_P_Show,label&"("&tmpstr&")$",GetArgueList(para(0),para(1),para(2)))
			If Err Then
				Response.Write "<br/>$show_bl$标签有错误，请检查参数"
				Response.Write Err.Description
				Response.End()
			End If
		End Select
		tmp2=1
	Wend
End Sub

Function show_log(n, l, order, action, sdate, classid, classname, subjectname, info)
	show_log = ""
	Dim rs, msql, ordersql, actionsql, classsql, rstmp, i, postname, posttime, userurl, ustr
	i = 0
	Select Case order
	Case 1
	   'ordersql = " order by logid desc"
	   ordersql = " order by addtime desc"
	Case 2
		ordersql = " order by iis desc"
	Case 3
		ordersql = " order by commentnum desc"
	End Select

	Select Case action
	Case 1
		actionsql = ""
	Case 2
		actionsql = " and isbest=1"
	End Select
	If classid = 0 Then
		classsql = ""
	Else
		set rs=oblog.execute("select id from oblog_logclass where parentpath like '"&classid&",%' OR parentpath like '%,"&classid&"' OR parentpath like '%,"&classid&",%'")
		While Not rs.EOF
			ustr=ustr&","&rs(0)
			rs.MoveNext
		Wend
		ustr=classid&ustr
		classsql=" and classid in ("&ustr&")"
		'classsql=" and classid="&clng(classid)
	End If
	msql="select top "&n&" topic,logfile,addtime,commentnum,iis,logid,classid,subjectid,author,blogname,nickname,user_dir,user_domain,user_domainroot,user_dir,oblog_user.userid,user_folder from oblog_log,oblog_user where oblog_user.userid=oblog_log.userid and ishide<>1 and isdraft=0 and passcheck=1 And oblog_log.isdel=0 And oblog_user.isdel=0 "
	If is_sqldata Then
		msql=msql&" and datediff(d,oblog_log.truetime,getdate())<"&cint(sdate)&" and oblog_log.blog_password=0 And (ispassword='' Or ispassword is null)"
	Else
		msql=msql&" and datediff('d',oblog_log.truetime,now())<"&cint(sdate)&" and oblog_log.blog_password=0 And (ispassword='' Or ispassword is null)"
	End If
	msql=msql&actionsql&classsql
	msql=msql&ordersql
	Set rs = oblog.execute(msql)
	show_log=show_log&"<ul>"
	Do While Not rs.EOF
		show_log=show_log&"<li>"
		If rs("nickname") <> "" Then
			postname = oblog.filt_html(rs("nickname"))
		Else
			postname = oblog.filt_html(rs(8))
		End If
		posttime = rs(2)
		If classname = 1 Then
			Set rstmp = oblog.execute("select id,classname from oblog_logclass where id=" & rs(6))
			If Not rstmp.EOF Then
				show_log=show_log&"<a href=list.asp?classid="&rstmp(0)&" target=_blank>〖"&rstmp(1)&"〗</a>"
			End If
		End If
		If subjectname = 1 Then
			Set rstmp = oblog.execute("select subjectid,subjectname from oblog_subject where subjectid=" & rs(7))
			If Not rstmp.EOF Then
				show_log=show_log&"<a href=blog.asp?name="&rs("author")&"&subjectid="&rstmp(0)&" target=_blank>["&oblog.filt_html(rstmp(1))&"]</a>"
			End If
		End If
		Dim topic
		If rs(0) <> "" Then
			topic = Replace(rs(0), "'", "")
			If topic <> "" Then
				If oblog.strLength(topic) > Int(l) Then
					topic = oblog.InterceptStr(topic, Int(l) - 3) & "..."
				End If
			End If
		End If
		show_log=show_log&"<a href="""&rs(1)&""" title="""&oblog.filt_html(rs(0))&""" target=_blank>"&oblog.filt_html(topic)&"</a>"
		If oblog.cacheConfig(5) = 1 Then
			userurl = "http://" & Trim(rs("user_domain")) & "." & Trim(rs("user_domainroot"))
		Else
			userurl = rs("user_dir") & "/" & rs("user_folder") & "/index." & f_ext
		End If
		Select Case CInt(info)
		Case 1
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_uname""><a href="&userurl&" target=_blank>"&postname&"</a></span><span class=""ob_log_c2"">,</span><span class=""ob_log_time"">"&formatdatetime(posttime,0)&"</span><span class=""ob_log_c1"">)</span>"
		Case 2
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_time"">"&posttime&"</span><span class=""ob_log_c1"">)</span>"
		Case 3
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_uname""><a href="&userurl&" target=_blank>"&postname&"</a></span><span class=""ob_log_c1"">)</span>"
		Case 4
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_uname""><a href="&userurl&" target=_blank>"&postname&"</a></span><span class=""ob_log_c2"">,</span><span class=""ob_log_num"">"&rs(4)&"</span><span class=""ob_log_c1"">)</span>"
		Case 5
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_num"">"&rs(4)&"</span><span class=""ob_log_c1"">)</span>"
		Case 6
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_uname""><a href="&userurl&" target=_blank>"&postname&"</a></span><span class=""ob_log_c2"">,</span><span class=""ob_log_time"">"&formatdatetime(posttime,1)&"</span><span class=""ob_log_c1"">)</span>"
		Case 7
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_time"">"&formatdatetime(posttime,1)&"</span><span class=""ob_log_c1"">)</span>"
		Case 8
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_num"">"&rs(3)&"</span><span class=""ob_log_c1"">)</span>"
		Case 9
			show_log=show_log&"<span class=""ob_log_c1"">(</span><span class=""ob_log_bname"">"&oblog.filt_html(rs("blogname"))&"<span><span class=""ob_log_c1"">)</span>"
		Case Else
		End Select
		show_log=show_log&"</li>"&vbcrlf
		rs.MoveNext
		i = i + 1
		If i >= Int(n) Then Exit Do
	Loop
	show_log=show_log & "</ul>"
	Set rs = Nothing
	Set rstmp = Nothing
End Function

Function show_userlog(userid,n, l, order,  subjectid,  info)
	Dim rs, strSql, strOrderSql, i, posttime,topic,strContent
	i = 0
	Select Case order
		Case 1
			'strOrderSql = " order by logid desc"
			strOrderSql = " order by addtime desc" 
		Case 2
			strOrderSql = " order by iis desc"
		Case 3
			strOrderSql = " order by commentnum desc"
	End Select           

	strSql = "Select Top "&n&" topic,logfile,addtime,commentnum,iis,logid,author,userid"    
	strSql = strSql & " from oblog_log where ishide<>1 and isdraft=0 and passcheck=1 and isdel=0 "
	strSql = strSql & "and blog_password=0  And (ispassword='' Or ispassword is null)"
	'过滤掉当日之后的日志
	If is_Sqldata=1 Then
		strSql = strSql & " And addtime<getdate() "
	Else
		strSql = strSql & " And addtime<Now "
	End If

	If subjectid<>0 And IsNumeric(subjectid) Then
		strSql = strSql & " And Subjectid=" & CLNG(subjectid)
	End If
	strSql = strSql & " And UserId=" & CLNG(Userid) & strOrderSql
	'Response.Write strSql
	Set rs = oblog.execute(strSql)
	strContent="<ul>"
	Do While Not rs.EOF
		strContent=strContent&"<li>"
		posttime = rs("addtime")
		If rs("topic") <> "" Then
			topic = Replace(rs("topic"), "'", "")
			If topic <> "" Then
				If oblog.strLength(topic) > Int(l) Then
					topic = oblog.InterceptStr(topic, Int(l) - 3) & "..."
				End If
			End If
		End If
		strContent=strContent&"<a href=""go.asp?logid=" & rs("logid") &""" title="""&oblog.filt_html(rs(0))&""" target=_blank>"&oblog.filt_html(topic)&"</a>"
		If  CInt(info)=1 Then
			strContent=strContent&"("&formatdatetime(posttime,1)&")"
		End If
		strContent=strContent&"</li>"&vbcrlf
		rs.MoveNext
		i = i + 1
		If i >= Int(n) Then Exit Do
	Loop
	show_userlog=strContent & "</ul>"
	strContent=""
	Set rs = Nothing
End Function

Function show_class(m)
	Dim rs
	'show_class="<a href=index.asp>首页("&blogcount&")</a><br>"
	Dim i, brstr
	show_class = ""
	m = Int(m)
	Set rs = oblog.execute("select id,classname from oblog_logclass Where idtype=0 And child=0 order by RootID,OrderID")
	If m = 0 Then
		While Not rs.EOF
			show_class=show_class&"<a href=list.asp?classid="&rs(0)&">"&rs(1)&"</a><br/>"
			rs.MoveNext
		Wend
	Else
		i = 0
		While Not rs.EOF
			i = i + 1
			If i = Int(m) Then
				brstr = "<br/>"
				i = 0
			Else
				brstr = ""
			End If
			show_class=show_class&"<a href=list.asp?classid="&rs(0)&">"&rs(1)&"</a> "&brstr
			rs.MoveNext
		Wend
		if right(show_class,6)="<br />" then show_class=left(show_class,len(show_class)-6)
	End If
	Set rs = Nothing
End Function

Function show_comment(n, l)
	Dim rs
	set rs=oblog.execute("select top "&n&" mainid,commenttopic,comment_user,addtime,commentid from [oblog_comment] where isdel=0 order by commentid desc")
	show_comment="<ul>"
	While Not rs.EOF
		show_comment=show_comment&"<li><a href='go.asp?logid="&rs(0)&"&commentid="&rs(4)&"' target=_blank title='"&oblog.filt_html(rs(2))&"回复于"&rs(3)&"'>"&oblog.InterceptStr(oblog.filt_html(rs(1)),clng(l))&"</a></li>"
		rs.MoveNext
	Wend
	show_comment=show_comment&"</ul>"
	Set rs = Nothing
End Function

Function show_subject(n)
	Dim i, rs
	i = 0
	'set rs=oblog.execute("select top "&n&" subjectid,oblog_subject.userid,subjectname,subjectlognum,user_dir,user_folder from [oblog_subject],oblog_user where oblog_subject.userid=oblog_user.userid and oblog_subject.oblog_subjecttype=0 order by subjectlognum desc")
	set rs=oblog.execute("Select a.*,b.username From (Select top " & n &" Subjectid,SubjectName,SubjectlogNum,userid From oBlog_subject where subjecttype=0 order by subjectlognum desc) a ,oblog_user b Where a.userid=b.userid")
	show_subject="<ul>"
	Do While Not rs.EOF
		show_subject=show_subject&"<li><a href='blog.asp?name="&rs("username")&"&subjectid="&rs("subjectid")&"' target=_blank>"&oblog.filt_html(rs("subjectname"))&"("&rs("SubjectlogNum")&")</a></li>"
		rs.MoveNext
		i = i + 1
		If i >= Int(n) Then Exit Do
	Loop
	show_subject=show_subject&"</ul>"
	Set rs = Nothing
End Function

Function show_blogupdate(n)
	Dim i, rs, userurl
	i = 0
	set rs=oblog.execute("select top "&n&" username,log_count,nickname,blogname,userid,user_dir,user_domain,user_domainroot,user_folder from [oblog_user] where lockuser=0 and isdel=0 order by log_count desc")
	show_blogupdate="<ul>"
	Do While Not rs.EOF
		If oblog.cacheConfig(5) = 1 Then
			userurl = "http://" & Trim(rs("user_domain")) & "." & Trim(rs("user_domainroot"))
		Else
			userurl = rs("user_dir") & "/" & rs("user_folder") & "/index." & f_ext
		End If
		If rs("blogname") <> "" Then
			show_blogupdate=show_blogupdate&"<li><a href="&userurl&" target=_blank>"&rs("blogname")&"("&rs("log_count")&")</a></li>"
		Else
			show_blogupdate=show_blogupdate&"<li><a href="&userurl&" target=_blank>"&rs("username")&"("&rs("log_count")&")</a></li>"
		End If
		rs.MoveNext
		i = i + 1
		If i >= Int(n) Then Exit Do
	Loop
	show_blogupdate=show_blogupdate&"</ul>"
	Set rs = Nothing
End Function

Function show_newblogger(n)
	Dim rs, userurl,userico
	set rs=oblog.execute("select top "&n&" username,log_count,nickname,blogname,userid,user_dir,user_domain,user_domainroot,user_folder from [oblog_user] where lockuser=0 and isdel=0 order by userid desc")
	show_newblogger="<ul>"
	While Not rs.EOF
		If oblog.cacheConfig(5) = 1 Then
			userurl = "http://" & Trim(rs("user_domain")) & "." & Trim(rs("user_domainroot"))
		Else
			userurl = rs("user_dir") & "/" & rs("user_folder") & "/index." & f_ext
		End If
		If rs(3) <> "" Then
			show_newblogger=show_newblogger&"<li><a href="&userurl&" target=_blank>"&rs(3)&"("&rs(1)&")</a></li>" & vbcrlf
		Else
			show_newblogger=show_newblogger&"<li><a href="&userurl&" target=_blank>"&rs(0)&"("&rs(1)&")</a></li>" & vbcrlf
		End If
		rs.MoveNext
	Wend
	show_newblogger=show_newblogger&"</ul>"
	Set rs = Nothing
End Function

Function show_bestblog(n)
	Dim i, rs, userurl
	i = 0
	set rs=oblog.execute("select top "&n&" username,log_count,nickname,blogname,userid,user_dir,user_domain,user_domainroot,user_folder from [oblog_user] where user_isbest=1 and isdel=0 order by log_count desc")
	show_bestblog="<ul>"
	Do While Not rs.EOF
		If oblog.cacheConfig(5) = 1 Then
			userurl = "http://" & Trim(rs("user_domain")) & "." & Trim(rs("user_domainroot"))
		Else
			userurl = rs("user_dir") & "/" & rs("user_folder") & "/index." & f_ext
		End If
		If rs(3) <> "" Then
			show_bestblog=show_bestblog&"<li><a href="""&userurl&""" target=""_blank"">"&rs(3)&"("&rs(1)&")</a></li>" & vbcrlf
		Else
			show_bestblog=show_bestblog&"<li><a href="""&userurl&""" target=""_blank"">"&rs(0)&"("&rs(1)&")</a></li>" & vbcrlf
		End If
		rs.MoveNext
		i = i + 1
		If i >= Int(n) Then Exit Do
	Loop
	show_bestblog=show_bestblog&"</ul>"
	Set rs = Nothing
End Function

Function show_count()
	Dim rs,lngToday,lngYesteday
	Set rs = oblog.execute("select count(logid) from oblog_log where datediff("&G_Sql_d&",truetime,"&G_Sql_Now&")=0  and isdel=0 ")
	lngToday=rs(0)
	Set rs = oblog.execute("select count(logid) from oblog_log where datediff("&G_Sql_d&",truetime,"&G_Sql_Now&")=1 and isdel=0 ")
	lngYesteday=rs(0)
	Set rs = Nothing
	show_count = "<ul><li>博客：" & oblog.setup(4, 0) & "</li>"
	show_count=show_count&"<li>日志："&oblog.setup(1,0)&"</li>"
	show_count=show_count&"<li>评论："&oblog.setup(2,0)&"</li>"
	show_count=show_count&"<li>留言："&oblog.setup(3,0)&"</li>"
	show_count=show_count&"<li>昨日："&lngYesteday&"</li>"
	show_count=show_count&"<li>今日："&lngToday&"</li></ul>"

End Function

Function show_sysxml()
	show_sysxml = "<a href='" & blogdir & "rss2.asp' target='_blank'><img src='Images/xml.gif' width='36' height='14' border='0'></a>"
End Function

Function show_friends()
	show_friends=OB_IIF(oblog.setup(6, 0),"")
End Function

Function show_placard()
	show_placard=OB_IIF(oblog.setup(5, 0),"")
End Function

Function show_bloger(m)
	Dim rs
	Dim i, brstr
	m = Int(m)
	Set rs = oblog.execute("select id,classname from oblog_userclass order by RootID,OrderID")
	If m = 0 Then
		While Not rs.EOF
			show_bloger=show_bloger&"<a href=listblogger.asp?usertype="&rs(0)&">"&rs(1)&"</a><br/>"
			rs.MoveNext
		Wend
	Else
		i = 0
		While Not rs.EOF
			i = i + 1
			If i = Int(m) Then
				brstr = "<br/>"
				i = 0
			Else
				brstr = ""
			End If
			show_bloger=show_bloger&"<a href=listblogger.asp?usertype="&rs(0)&">"&rs(1)&"</a> "&brstr
			rs.MoveNext
		Wend
	End If
	Set rs = Nothing
End Function

Function show_search(i)
	If i = 0 Then i = "" Else i = "<br />"
	show_search = "<form name='search' method='post' action='list.asp'>"
	show_search=show_search&"<select name='selecttype' id='selecttype'>"
	show_search=show_search&"<option value='topic' selected>日志标题</option>"
	show_search=show_search&"<option value='logtext'>日志内容</option>"
	show_search=show_search&"<option value='id'>博客名称</option></select>"&i
	show_search=show_search&"<input name='keyword' type='text' id='keyword' size='16' maxlength='40'>"
	show_search=show_search&" <input type='submit' name='Submit' value='搜索'></form>"
End Function

Function show_cityblogger(i)
	show_cityblogger = "<form name=""oblogform"" action=""listblogger.asp"">" & oblog.type_city("", "") & " <input type='submit' value='搜索'></form>"
	If i = 1 Then show_cityblogger = Replace(show_cityblogger, "<select name='city'", "<br /><select name='city'")
End Function

Function show_newphoto(n, i, w, h)
	Dim rs, sReadMe,surl,imgsrc,fso,wstr,hstr
	Set fso = server.CreateObject(oblog.CacheCompont(1))
	If i = 1 Then i = "<br />" Else i = ""
	if w<>0 or w<>"" then wstr="width="""&w&""""
	if h<>0 or h<>"" then hstr="height="""&h&"""" 
	Set rs = oblog.execute("select top " & CLng(n) & " file_path,file_readme,oblog_upfile.userid,user_dir,username,nickname,logid from [oblog_user],oblog_upfile where oblog_user.userid=oblog_upfile.userid and isphoto=1 and ispower=0  and oblog_user.isdel=0 order by fileid desc")
	While Not rs.EOF
		If IsNull(rs(1)) Then
			sReadMe = ""
		Else
			sReadMe = oblog.filt_html(rs(1))
		End If
		if rs("logid")=0 or isnull(rs("logid")) then 
			surl="<a href='"&rs("file_path")&"' target='_blank'>"
		else
			surl="<a href='go.asp?albumid="&rs("userid")&"' target='_blank'>"
		end if
		imgsrc=rs(0)
		imgsrc=replace(imgsrc,right(imgsrc,3),"jpg")
		imgsrc=replace(imgsrc,right(imgsrc,len(imgsrc)-InstrRev(imgsrc,"/")),"pre"&right(imgsrc,len(imgsrc)-InstrRev(imgsrc,"/")))
		if  not fso.FileExists(Server.MapPath(imgsrc)) then
			imgsrc=rs(0)
		end if
		show_newphoto=show_newphoto&"<a href='go.asp?albumid="&rs("userid")&"' target='_blank'><img src="""&imgsrc&""" "&wstr&" "&hstr&" hspace=""6"" border=""0"" vspace=""6"" alt='"& sReadMe &"' /></a>"&i
		rs.MoveNext
	Wend
	Set rs = Nothing
End Function

Function show_blogstar()
	Dim rs
	Set rs = oblog.execute("select top 1 * from oblog_blogstar where ispass=1 order by id desc")
	If Not rs.EOF Then
		show_blogstar = "<div><a href='" & rs("userurl") & "' target='_blank'><img src=""" & rs("picurl") & """  hspace=""3"" border=""0"" vspace=""3"" alt='" & oblog.filt_html(rs("blogname")) & "' /></a></div>"
		show_blogstar=show_blogstar&"<div>博客："&"<a href='"&rs("userurl")&"' target='_blank'>"&oblog.filt_html(rs("blogname"))&"</a></div>"
		show_blogstar=show_blogstar&"<div>简介："&oblog.filt_html(rs("info"))&"</div>"
	Else
		show_blogstar = " "
	End If
	Set rs = Nothing
End Function

Public Function show_blogstar2(iNumber, iPerline, iWidth, iHeight)
	Dim rs, iCount, sLine
	If Not IsNumeric(iNumber) Then
		iNumber = 1
	Else
		iNumber = CLng(iNumber)
	End If
	'iWidth=160
	'iHeight=160
	If iNumber = 0 Then iNumber = 1
	Set rs = oblog.execute("select top " & iNumber & " * from oblog_blogstar where ispass=1 order by id desc")
	If Not rs.EOF Then
		show_blogstar2 = "<table style=""table-layout: fixed"" width=" & (iWidth + 2) * iPerline & " border=0><tr>"
		If iNumber = 1 Then
			sLine = "<td nowrap  valign=top style=""width:" & (iWidth + 2) & "px;white-space:nowrap;text-overflow : clip; overflow : hidden;""><a href='" & rs("userurl") & "' target='_blank'><img src=""" & rs("picurl") & """  hspace=""3"" border=""0"" vspace=""3"" alt='" & oblog.filt_html(rs("blogname")) & "' onload=""javascript:if(this.width>" & iWidth & ") this.style.width=" & iWidth & ";"" /></a><BR/>"
			sLine = sLine & "博客：" & "<a href='" & rs("userurl") & "' target='_blank'>" & oblog.filt_html(rs("blogname")) & "</a><BR/>"
			sLine = sLine & "简介：" & oblog.filt_html(rs("info")) & "</td>"
			show_blogstar2 = show_blogstar2 & sLine & "</tr>" & vbCrLf
		'多图片时强制大小统一
		Else
			iCount = 1
			Do While Not rs.EOF
				sLine = "<td nowrap  valign=top style=""width:" & (iWidth + 2) & "px;white-space:nowrap""><a href='" & rs("userurl") & "' target='_blank'><img src=""" & rs("picurl") & """  hspace=""3"" border=""0"" vspace=""3"" alt='" & oblog.filt_html(rs("blogname")) & "' width=" & iWidth & " height=" & iHeight & " /></a><BR/>"
				sLine = sLine & "博客：" & "<a href='" & rs("userurl") & "' target='_blank'>" & oblog.filt_html(rs("blogname")) & "</a><BR/>"
				sLine = sLine & "简介：" & oblog.filt_html(rs("info")) & "</td>" & vbCrLf
				show_blogstar2 = show_blogstar2 & sLine
				If iCount Mod iPerline = 0 Then show_blogstar2 = show_blogstar2 & "</tr>"
				iCount = iCount + 1
				rs.MoveNext
			Loop
			If Right(show_blogstar2, 5) <> "</tr>" Then show_blogstar2 = show_blogstar2 & "</tr>"
		End If
		show_blogstar2 = show_blogstar2 & "</table>"
	Else
		show_blogstar2 = " "
	End If
	rs.Close
	Set rs = Nothing
End Function

'获取标签
's 表现形式 1-列表形式,2-云图形式
'n 标签数目
'x 排序方式 0 自然序/1频度最高
'y 每行显示数目
Function GetHotTags(s,n,x,y)
	Dim sContent,sSql,rst,iFont,iFontSize,i,iFontFamily
	Dim sSplit
	sSplit="&nbsp;&nbsp;"
	sSql="Select top "& n & " * From oblog_Tags Where iNum>0 "
	If s=1 Then sSql= sSql & " Order By iNum Desc"
	Set rst=conn.Execute(sSql)
	If rst.Eof Then
		sContent=""
	Else
		Do While Not rst.Eof
			If s=1 Then
				sContent= sContent & "<span><a href=""tags.asp?tagid=" & rst("tagID") &""">" & rst("Name")& "<span>(" & rst("iNum") &  ")</span></a></span>" & sSPlit
			Else
				iFont=rst("iNum") Mod 100
				If iFont=0 Then iFontSize=10
				If iFont>-1 And iFont<20 Then iFontSize=10 + iFont
				if iFontSize>18 and iFontSize<23 then iFontSize=20
				if iFontSize>23 and iFontSize<28 then iFontSize=25
				if iFontSize>28 then iFontSize=30
				if iFontSize >18 then iFontFamily="黑体,"
				sContent= sContent & "<a href=""tags.asp?tagid=" & rst("tagID") & """ title="""& rst("Name") &"""><span style=""font-size:"& iFontSize &"px;line-height:26px;font-family:"&iFontFamily&"Arial, Helvetica"">" & Left(rst("Name"),10)& "</span></a>" & sSPlit
			End If
			i=i+1
			If i Mod y = 0 Then
				sContent = sContent &  "<br />" & vbCrLf
			End If			
			rst.Movenext
		Loop
	End If
	rst.Close
	Set rst=Nothing
	GetHotTags= sContent
	sContent=""
End Function

'x:1- 最新创建/2-最活跃群组(贴数最多)/3-规模大(人数最多) / 4-推荐群组
'n: 数目
'l: 题目显示长度
'y: 是否显示图标
'w:	图标宽度，不写则默认50
'h: 图标高度，不写则默认50
Function GetTeams(x,n,l,y,w,h)
	Dim rs,Sql,sRet,sIco
	Sql="Select top " & n & " teamid,t_name,t_ico,icount0,(icount1+icount2) From oblog_team Where istate=3 and isdel=0  " 
	Select Case x
		Case 1
			Sql= Sql & " Order By teamid Desc"
		Case 2
			Sql= Sql & " Order By (icount1+icount2) Desc"
		Case 3
			Sql= Sql & " Order By icount0 Desc"
		Case 4
			Sql= Sql & " and isbest=1"
	End Select
	Set rs=oblog.Execute(Sql)
	sRet="<div><ul>"
	Do While Not rs.Eof 
		sRet=sRet & "<li>" 
		If y=1 Then
			If w="" Then w=50:h=50
			sIco=LCase(Ob_IIF(rs(2),"images/ico_default.gif"))			
			If Left(sico,7)<>"http://" Then sico=blogdir & sico
			sRet=sRet & "<img src=""" & sico & """ width=""" & w &""" height=""" & h &"""/><br />"
		End if	
		sRet=sRet & "<a href=""group.asp?gid=" & rs(0) & """ target=""_blank"">" & Left(oblog.filt_html((rs(1))),l) & "</a>(" & rs(3) & "/" & rs(4) & ")"
		sRet=sRet & "</li>" & Vbcrlf
		rs.movenext
	Loop
	Set rs=Nothing
	sRet=sRet & "</ul></div>"
	GetTeams=sRet
End Function

'获取群组文章
'teamid: 0 所有群组;如果是选择多个群组,则把群组ID用|分隔开,如1|2|8
'postnum: 帖子数目
'l:帖子主题显示字数
'u:是否显示用户名 0/1
't:是否显示发帖时间 0/1
Function GetPosts(teamid,postnum,l,u,t)
	Dim rs,sql,sRet,sAddon
	Sql="Select Top " & postnum & " teamid,postid,topic,addtime,author,userid From oblog_teampost Where idepth=0 and isdel=0 "
	If teamid<>"" And teamid<>"0" Then
		teamid=Replace(teamid,"|",",")
		Sql=Sql & " And teamid In (" & teamid & ") "
	End If
	Sql=Sql & " Order by postid Desc"
	Set rs=oblog.Execute(Sql)
	sRet="<ul>"
	Do While Not rs.Eof
		sAddon=""
		sRet=sRet & "<li><a href=""group.asp?gid=" & rs(0) & "&pid=" & rs(1) & """ target=""_blank"">" & oblog.Filt_html(Left(rs(2),l)) & "</a>"
		If u=1 Then sAddon=rs(4)
		if t=1 Then
			If sAddon<>"" Then sAddon=sAddon & ","
			sAddon=sAddon & rs(3)
		End If
		If sAddon<>"" Then sAddon="(" & sAddon & ")"
		sRet=sRet & sAddon & "</li>"
		rs.Movenext
	Loop
	Set rs = Nothing
	sRet=sRet & "</ul>"
	GetPosts=sRet
End Function

'最受欢迎的用户,计算方法
'user_siterefu_num+comment_count*1.5+message_count*1.5+sub_num*3
'访问数+回复数*1.5+留言数*1.5+被订阅数*3
't 是否显示用户头像
Function GetHotUsers(n,t)
	Dim rs, userurl,userico,i
	set rs=oblog.execute("select top "&n&" username,nickname,blogname,userid,user_dir,user_domain,user_domainroot,user_folder,user_icon1 from [oblog_user] where lockuser=0 and isdel=0 order by (user_siterefu_num+comment_count*1.5+message_count*1.5+sub_num*3) desc")
	GetHotUsers="<ul>"
	While Not rs.EOF
		If oblog.cacheConfig(5) = 1 Then
			userurl = "http://" & Trim(rs("user_domain")) & "." & Trim(rs("user_domainroot"))
		Else
			userurl = rs("user_dir") & "/" & rs("user_folder") & "/index." & f_ext
		End If
		If t=1 Then userico="<img src=""" & OB_IIF(rs(8),"images/ico_default.gif") & """ width=""48"" height=""48"" border='0' /><br />"
		GetHotUsers=GetHotUsers&"<li><a href="&userurl&" target=""_blank"">"&userico& rs(2)&"</a></li>" & vbcrlf      
		rs.MoveNext
	Wend
	GetHotUsers=GetHotUsers&"</ul>"
	Set rs = Nothing
End Function

function TreeClass(n)
	dim Table_Name,wsql,toptitle,fname
	select case n
		case "user"
			Table_Name="oblog_userclass"
			wsql=""
			toptitle="用户类别"
			fname="listblogger.asp?usertype="
		case "log"
			Table_Name="oblog_logclass"
			wsql=" where idType=0 "
			toptitle="日志类别"
			fname="list.asp?classid="
		case "photo"
			Table_Name="oblog_logclass"
			wsql=" where idType=1 "
			toptitle="相片类别"
			fname="photo.asp?classid="
		case "group"
			Table_Name="oblog_logclass"
			toptitle=P_QQ_NAME& "类别"
			wsql=" where idType=2 "		
			fname="groups.asp?classid="
	end select
	dim sqlClass,rsClass,D_String
	sqlClass="select * From "&Table_Name&wsql&"  order by RootID,OrderID"
	set rsClass=oblog.execute(sqlClass)
	'把查询到的内容存放到字符串里，在JS中调用该字符串
	do	while not rsClass.eof
		D_String=D_String&"|"&rsClass("id")&","&rsClass("parentid")&",<a href='"&fname & rsClass("id") & "'>"&rsClass("classname")&"</a>,"&rsClass("readme")
		rsClass.movenext
	loop
	TreeClass="<script src='inc/tree.js'></script><script language='javascript' type='text/javascript'>var J_String,J_First,J_Second;var i,j;d = new dTree('d');d.add(0,-1,'<strong>"&toptitle&"</strong>');J_String="""&D_String&""";J_First=J_String.split('|');for(i=0;i<J_First.length;i++){J_Second=J_First[i].split(',');d.add(J_Second[0],J_Second[1],J_Second[2],'',J_Second[3]);}document.write(d);</script>"
	set rsClass=nothing
end function

'获得辩论列表
'n:显示条数;
'l:字符数目;
's:显示类型,1最新/2参与人数最多
Function GetArgueList(n,l,s)
	Dim sRet,Sql,rs,sState
	If s="1" Then
		'最新
		Sql="Select top " & n & " argueid,topic,a_ico,actions,actions1,actions2,actions3 From oblog_argue Where istate=2 Order By argueid Desc"
	Else
		'最热的
		Sql="Select top " & n & " argueid,topic,a_ico,actions,actions1,actions2,actions3  From oblog_argue Where istate=2 Order By actions Desc"
	End If
	'Response.Write Sql
	Set rs=oblog.Execute(Sql)
	Do While Not rs.Eof
		sRet=sRet & "<li><a href=""bl.asp?cmd=show&blid=" & rs("argueid") & """ target=""_blank"">" & Left(rs("topic"),l) & "</a><br/><font color=""red"">正</font>&nbsp;" & rs("actions1") & "&nbsp;&nbsp;<font color=""blue"">反</font>&nbsp;" & rs("actions2") & "&nbsp;&nbsp;<font color=""green"">参与</font>&nbsp;" &  rs("actions") & "</li>"
		rs.Movenext
	Loop
	Set rs=Nothing
	GetArgueList=sRet
	sRet=""
End Function
%>