<%
'=========================================================
' E路社区明星Mini版
' Version:      1.0.0
' Author:				Kafree
' Homepage:			http://www.eLook.net.cn , http://www.8esky.com
' Email:				Kafree409(at)21cn.com
' Oicq:					13532896
' Description:	
' Copyright (C) 2005-2006 ELook.net.cn. All rights reserved.
'=========================================================
Const StarsType=1	'社区明星统计按照什么数据：1-每日发贴量 2-每周发贴量	3-每月发贴量 4-每年发贴量 5-发贴总数量
Const StarsNum=10	'显示多少个社区明星
Const StarsCacheName="Elook_Stars"	'社区明星缓存名称

Sub Elook_DelCahe(MyCaheName)
	Application.Lock
	'Application.Contents.Remove(Dvbbs.CacheName & "_" & MyCaheName &"_-time")
	Application.Contents.Remove(Dvbbs.CacheName & "_" & MyCaheName)
	Application.unLock
End Sub

'Elook_DelCahe(StarsCacheName)
Sub Elook_StarData(iAvatarType,iTop)
	Dim Sql,Rs
	Dim SqlDate
	If IsSqlDataBase Then
		SqlDate="Cast(convert(char(10), getdate(),120) As DateTime)"
	Else
		SqlDate="Date()"
	End If
	Select Case iAvatarType
		Case 1
			'Sql="select top " & iTop & " B.username,U.UserPost,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday from "&Dvbbs.NowUseBBS&" B Inner Join Dv_User U On U.UserId=B.PostUserId Where B.locktopic=0 And B.DateAndTime>" & SqlDate & " Group By B.username,U.UserPost,U.Usersex,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday Order by count(B.username) desc"	'每日发贴量
			Sql="select top " & iTop & " Count(B.username) As UserPosts,U.UserPost,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday,U.UserName from "&Dvbbs.NowUseBBS&" B Inner Join Dv_User U On U.UserId=B.PostUserId Where B.locktopic=0 And B.DateAndTime>" & SqlDate & " Group By B.username,U.UserPost,U.Usersex,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday,U.UserName Order by count(B.username) desc"	'每日发贴量
		Case 2
			If IsSqlDataBase Then
				Sql="select top " & iTop & " B.username,U.UserPost,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday from "&Dvbbs.NowUseBBS&" B Inner Join Dv_User U On U.UserId=B.PostUserId Where B.locktopic=0 And (B.DateAndTime>" & SqlDate & "-DatePart(WeekDay," & SqlDate & ")-1) Group By B.username,U.UserPost,U.Usersex,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday Order by count(B.username) desc"	'每周发贴量
			Else
				Sql="select top " & iTop & " B.username,U.UserPost,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday from "&Dvbbs.NowUseBBS&" B Inner Join Dv_User U On U.UserId=B.PostUserId Where B.locktopic=0 And (B.DateAndTime>" & SqlDate & "-WeekDay(" & SqlDate & ",2)) Group By B.username,U.UserPost,U.Usersex,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday Order by count(B.username) desc"	'每周发贴量
			End If
		Case 3
			Sql="select top " & iTop & " B.username,U.UserPost,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday from "&Dvbbs.NowUseBBS&" B Inner Join Dv_User U On U.UserId=B.PostUserId Where B.locktopic=0 And Year(B.DateAndTime)=Year(" & SqlDate & ") And Month(B.DateAndTime)=Month(" & SqlDate & ") Group By B.username,U.UserPost,U.Usersex,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday Order by count(B.username) desc"	'每月发贴量
		Case 4
			Sql="select top " & iTop & " B.username,U.UserPost,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday from "&Dvbbs.NowUseBBS&" B Inner Join Dv_User U On U.UserId=B.PostUserId Where B.locktopic=0 And Year(B.DateAndTime)=Year(" & SqlDate & ") Group By B.username,U.UserPost,U.Usersex,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday Order by count(B.username) desc"	'每年发贴量
		Case 5
			Sql="select top " & iTop & " username,UserPost,Usersex,Userclass,UserEP,JoinDate,UserID,UserToday from Dv_User Order by UserPost Desc"	'发贴总数量
		Case else
			Sql="select top " & iTop & " B.username,U.UserPost,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday from "&Dvbbs.NowUseBBS&" B Inner Join Dv_User U On U.UserId=B.PostUserId Where B.locktopic=0 And B.DateAndTime>" & SqlDate & " Group By B.username,U.UserPost,U.Usersex,U.Usersex,U.Userclass,U.UserEP,U.JoinDate,U.UserID,U.UserToday Order by count(B.username) desc"	'每日发贴量
	End Select
	Set Rs=Dvbbs.Execute(Sql)
	Set Application(Dvbbs.CacheName & "_" & StarsCacheName)=Dvbbs.RecordsetToxml(Rs,"user","stardata")
	Set Rs=Nothing
	Application(Dvbbs.CacheName & "_" & StarsCacheName).documentElement.attributes.setNamedItem(Application(Dvbbs.CacheName & "_" & StarsCacheName).createNode(2,"starsnum","")).text=StarsNum
	Application(Dvbbs.CacheName & "_" & StarsCacheName).documentElement.attributes.setNamedItem(Application(Dvbbs.CacheName & "_" & StarsCacheName).createNode(2,"date","")).text=Date()
End Sub
%>