<!--#include file="conn.asp"-->
<%
	dim blogurl,userurl
    dim rs,n
	blogurl=trim(Application(cachename&"info")(6))
	if trim(request("n"))<>"" and IsNumeric(request("n")) then
		n=cint(request("n"))
	else
		n=1
	end if

	select case cint(request("orders"))
	case 1
		call tongji()
	case 2
		call topuser()
	case 3
		call adduser()
	case 4
		call listclass()
	case 5
		call listsubject()
	case 6
		call listbestblog()
	case 7
		'call showlogin()
	case 8
		call showplace()
	case 9
		call showusertype()
	case else
		call tongji()
	end select

            
sub tongji()
	dim rs,logcount,commentcount,messagecount,usercount,siterefu_num
	dim today_log,yesterday_log
	set rs=conn.execute("select logcount,commentcount,messagecount,usercount,siterefu_num from bloginfo")
	logcount=rs(0)
	commentcount=rs(1)
	messagecount=rs(2)
	usercount=rs(3)
	siterefu_num=rs(4)
	if issqldate then
		set rs=conn.execute("select count(id) from blog where datediff(d,addtime,GetDate())=0")
	else
		set rs=conn.execute("select count(id) from blog where datediff('d',addtime,now())=0")
	end if
	today_log=rs(0)
	if issqldate then
		set rs=conn.execute("select count(id) from blog where datediff(d,addtime,GetDate())=1")
	else	
		set rs=conn.execute("select count(id) from blog where datediff('d',addtime,now())=1")
	end if
	yesterday_log=rs(0)

	%> 
 document.write('◎- 博客总数 <font color=green><%=usercount%></font><br> ◎- 日志总数 <font color=green><%=logcount%></font><br> ◎- 评论总数 <font color=green><%=commentcount%></font><br> ◎- 留言总数 <font color=green><%=messagecount%></font>');
 document.write('<br> ◎- 今天日志 <font color=red><%=Today_log%></font><br> ◎- 昨天日志 <font color=green><%=yesterday_log%></font></font>')

<%
	set rs=nothing
	call closeconn()
end sub

sub topuser()
	dim i,blogname
	i=0
	set rs=conn.execute("select top "&n&" username,logcount,blogname from [user] order by logcount desc")
	
	do while Not RS.Eof and n>i
	if trim(rs(2))<>"" then
		blogname=replace(rs(2),"'","")
	else
		blogname=replace(rs(0),"'","")
	end if
	if Application(cachename&"info")(32)="true" then
		userurl="http://"&trim(rs(0))&"."&trim(Application(cachename&"info")(6))
	else
		userurl=blogurl&"blog.asp?name="&trim(rs(0))
	end if
	response.write "document.write('<FONT color=#800000 style=font-family:webdings>4</FONT><span style=""font-size:9pt;line-height: 15pt""><a href="&userurl&" target=_blank title=查看"&rs(0)&"的blog页>');"
    response.write "document.write('"&blogname&"("&rs(1)&")</a>');"
	response.write "document.write('</span><br>');"
	rs.MoveNext
	i=i+1
	Loop
	set rs=nothing
	call closeconn()
end sub

sub adduser()
	set rs=conn.execute("select top "&n&" username from [user] order by userid desc")
	do while Not RS.Eof
	if Application(cachename&"info")(32)="true" then
		userurl="http://"&trim(rs(0))&"."&trim(Application(cachename&"info")(6))
	else
		userurl=blogurl&"blog.asp?name="&trim(rs(0))
	end if

	response.write "document.write('<FONT color=#800000 style=font-family:webdings>4</FONT><span style=""font-size:9pt;line-height: 15pt""><a href="&userurl&" target=_blank title=查看"&rs(0)&"的blog页面>');"
        response.write "document.write('"&rs(0)&"</a>');"
	response.write "document.write('</span><br>');"
	rs.MoveNext
	Loop
	set rs=nothing
	call closeconn()
end sub

sub listclass()
	set rs=conn.execute("select id,classname,classlognum from [classname] order by ordernum asc")
	do while Not RS.Eof
	response.write "document.write('<FONT color=#800000 style=font-family:webdings>4</FONT><span style=""font-size:9pt;line-height: 15pt""><a href="&blogurl&"index.asp?classid="& rs(0) &" target=_blank title=进入blog分类["&rs(1)&"]>');"
        response.write "document.write('"&rs(1)&"("&rs(2)&")</a>');"
	response.write "document.write('</span><br>');"
	rs.MoveNext
	Loop
	set rs=nothing
	call closeconn()
end sub

sub listsubject()
	dim i
	i=0
	set rs=conn.execute("select top "&n&" id,subjectname,subjectlognum,username from [subject] order by subjectlognum desc")
	do while Not RS.Eof and n>i
	response.write "document.write('<FONT color=#800000 style=font-family:webdings>4</FONT><span style=""font-size:9pt;line-height: 15pt""><a href="&blogurl&"blog.asp?name="& rs(3) &"&subjectid="&rs(0)&" target=_blank title=进入"&rs(3)&"的专题["&rs(1)&"]>');"
    response.write "document.write('"&rs(1)&"("&rs(2)&")</a>');"
	response.write "document.write('</span><br>');"
	rs.MoveNext
	i=i+1
	Loop
	set rs=nothing
	call closeconn()
end sub

sub listbestblog()
	dim blogname,i
	set rs=conn.execute("select top "&n&" username,blogname,logcount from [user] where userisbest='true' order by logcount desc")
	i=0
	do while Not RS.Eof and n>i
	if trim(rs(1))<>"" then
		blogname=rs(1)
	else
		blogname=rs(0)
	end if
	if Application(cachename&"info")(32)="true" then
		userurl="http://"&trim(rs(0))&"."&trim(Application(cachename&"info")(6))
	else
		userurl=blogurl&"blog.asp?name="&trim(rs(0))
	end if
	response.write "document.write('<FONT color=#800000 style=font-family:webdings>4</FONT><span style=""font-size:9pt;line-height: 15pt""><a href="&userurl&" target=_blank title=查看"&blogname&"的blog页面>');"
    response.write "document.write('"&blogname&"("&rs(2)&")</a>');"
	response.write "document.write('</span><br>');"
	rs.MoveNext
	i=i+1
	Loop
	set rs=nothing
	call closeconn()
end sub

sub showlogin()
	response.write "document.write('<table align=center width=100% border=0 cellspacing=0 celpladding=0>');"
	response.write "document.write('<form action="&blogurl&"User_ChkLogin.asp method=post name=UserLogin onSubmit=return CheckForm();>');"
	response.write "document.write('<tr><td height=25 align=right>用户名称：</td><td height=25><input name=UserName type=text id=UserName size=12 maxlength=20></td></tr>');"
	response.write "document.write('<tr><td height=25 align=right>登陆密码：</td><td height=25><input name=Password type=password id=Password size=12 maxlength=20></td></tr>');"
	response.write "document.write('<tr><td height=25 align=right>Cookie：</td><td height=25><select name=CookieDate><option selected value=0>不保存</option><option value=1>保存一天</option>');"
	response.write "document.write('<option value=2>保存一月</option><option value=3>保存一年</option></select></td></tr>');"
	response.write "document.write('<tr align=center><td height=30 colspan=2><input name=Login type=submit id=Login value= 登录 > ');"	
	response.write "document.write('<a href="&blogurl&"User_Reg.asp target=_blank>用户注册</a>&nbsp;&nbsp;<a href="&blogurl&"User_GetPassword.asp>忘记密码</a><br></td>');"	
	response.write "document.write('</tr></form></table>');"
end sub

sub showplace()
	set rs=conn.execute("select sitePlacard from bloginfo")
	response.write "document.write('"&Replace(Replace(Replace(Replace(rs(0),"\","\\"),"'","\'"),VbCrLf,"\n"),chr(13),"")&"');"   
	set rs=nothing
	call closeconn()
end sub

sub showusertype()
	set rs=conn.execute("select id,typename from [usertype] order by ordernum asc")
	do while Not RS.Eof
	response.write "document.write('<FONT color=#800000 style=font-family:webdings>4</FONT><span style=""font-size:9pt;line-height: 15pt""><a href="&blogurl&"list.asp?usertype="& rs(0) &" target=_blank title="&rs(1)&"的博客列表>');"
    response.write "document.write('"&rs(1)&"</a>');"
	response.write "document.write('</span><br>');"
	rs.MoveNext
	Loop
	set rs=nothing
	call closeconn()
end sub

function HTMLEncode(fString)
if not isnull(fString) then
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")
    fString = Replace(fString, CHR(32), "&nbsp;")
    fString = Replace(fString, CHR(9), "&nbsp;")
    fString = Replace(fString, CHR(34), "&quot;")
    fString = Replace(fString, CHR(39), "&#39;")
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10) & CHR(10), "&nbsp; ")
    fString = Replace(fString, CHR(10), "&nbsp; ")

    HTMLEncode = fString
end if
end function

%>