Most viewed Topics of the past 7 or 30 days - نوشته شده در (1242 Views)
New Member
kyodai
مطلب: 74
74
Well same as the "most replied to topics" pages, these 2 neat little pages enable you to view the 5 Most viewed threads of the past 7 or 30 days. Surprisingly the result differs a lot (At leats on my forums) from the "most replied" topics so i felt i'd post this one as well.

Again: This is just one simply SQL query packaged in a neat website, really nothing big. But it gives you a good overview which topics attracted most views. Definitely more for the curious people who wanna get a quick overview about "Whats hot" these days...


smile

Enjoy!

http://www.tankraider.com/userup/1297812865.zip
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
Here you go. I incorporated both views in one program, using a radio button to toggle between them. I also replaced hard-coded data with Snitz variables so they'll work on all forums.
Save as "countviews.asp"

Code:

<%
'###############################################################################
'##
'## Snitz Forums 2000 v3.4.07
'##
'###############################################################################
'##
'## Copyright © 2000-09 Michael Anderson, Pierre Gorissen,
'## Huw Reddick and Richard Kinser
'##
'## This program is free. You can redistribute and/or modify it under the
'## terms of the GNU General Public License as published by the Free Software
'## Foundation; either version 2 or (at your option) any later version. '##
'## All copyright notices regarding Snitz Forums 2000 must remain intact in
'## the scripts and in the HTML output. The "powered by" text/logo with a
'## link back to http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet. '##
'## This program is distributed in the hope that it will be useful but
'## WITHOUT ANY WARRANTY; without even an implied warranty of MERCHANTABILITY
'## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
'## for more details. '##
'## You should have received a copy of the GNU General Public License along
'## with this program; if not, write to:
'##
'## Free Software Foundation, Inc. '## 59 Temple Place, Suite 330
'## Boston, MA 02111-1307
'##
'## Support can be obtained from our support forums at:
'##
'## http://forum.snitz.com
'##
'## Correspondence and marketing questions can be sent to:
'##
'## manderson@snitz.com
'##
'###############################################################################
'##
'## Based on Kyodai's CountXViews
'##
'###############################################################################
%>
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_header.asp" -->
<%
If mLev > 1 Then
Response.Write "<table border=""0"" width=""100%"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td width=""33%"" align=""left"" nowrap><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" " & getCurrentIcon(strIconFolderOpen,"","") & " <a href=""default.asp"">All Forums</a><br />" & vbNewLine & _
" " & getCurrentIcon(strIconBlank,"","") & getCurrentIcon(strIconBar,"","") & getCurrentIcon(strIconFolderOpenTopic,"","") & " Topic Activity<br /></font></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
"</table><br>" & vbNewLine
intPeriod = 30
If Request.Form("Duration")<>"30" Then
intPeriod = 7
end if
datActivityDays = DateAdd("d", -intPeriod, Date())
myActivityDate = DateToStr(datActivityDays)
Response.Write "<table align=""center"" width=""100%"" bgColor=""" & strTableBorderColor & """ style=""border-collapse:collapse"" cellpadding=""4"" cellspacing=""1"" border=""1"">" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td colspan=""4"" align=""center"" width=""100%"" bgColor=""" & strPopupTableColor & """>" & vbNewLine & _
" <form action=""CountViews.asp"" method=""post"">" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strCategoryFontColor & """ size=""" & strHeaderFontSize+2 & """>Activity Monitor<br><small>(Most Viewed Topics in Past " & _
" <input type=""radio"" class=""radio"" name=""Duration"" value=""30""" & chkRadio(intPeriod,30,true) & ">30" & _
" <input type=""radio"" class=""radio"" name=""Duration"" value=""7""" & chkRadio(intPeriod,7,true) & ">7 Days)</small><br>" & _
" <input type=""submit"" name=""Submit"" value=""Submit"">" & _
" </font>" & _
" </form>" & _
" </td>" & _
" </tr>" & _
" <tr valign=""middle"">" & vbNewLine & _
" <td align=""center"" width=""5%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>COUNT</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""10%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>AUTHOR</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""5%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>TOPIC</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""80%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>SUBJECT</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine
Set rsTopic = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT TOP 5 T_VIEW_COUNT, T_SUBJECT, T_AUTHOR, TOPIC_ID FROM " & strTablePrefix & "TOPICS WHERE T_DATE > '" & myActivityDate & "' ORDER BY T_VIEW_COUNT DESC"
rsTopic.Open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
If rsTopic.EOF Then
Response.Write "<tr><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """>None Viewed</td></tr>"
Else
il=0
im=0
rsTopic.MoveFirst
Do while NOT rsTopic.EOF
CColor = strForumCellColor
if il<>0 then CColor = strForumFirstCellColor
Response.Write "<font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strForumFontColor & """>" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td align=""center"" width=""5%"" bgColor=" & CColor & ">" & vbNewLine & _
rsTopic("T_VIEW_COUNT") & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""10%"" bgColor=" & CColor & ">" & vbNewLine & _
GetMemberName(rsTopic("T_AUTHOR")) & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""5%"" bgColor=" & CColor & ">" & vbNewLine & _
" <a href=""topic.asp?TOPIC_ID=" & rsTopic("TOPIC_ID") &""">" & rsTopic("TOPIC_ID") & "</a>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""80%"" bgColor=" & CColor & ">" & vbNewLine & _
rsTopic("T_SUBJECT") & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </font>" & vbNewLine
il=1-il
im=im+1
if im=5 then exit do
rsTopic.MoveNext
Loop
rsTopic.Close
End If
Set rsTopic = Nothing
Response.Write "</table>"
Else
Response.Write "<center>Unauthorized access.<br><br></center>" & vbNewLine & _
" <meta http-equiv=""Refresh"" content=""2; URL=default.asp"">" & vbNewLine
End If
WriteFooter
%>
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
Here's an all-in-one (Reply & View activity), with toggle period:

Save as "counts.asp"

Code:

<%
'###############################################################################
'##
'## Snitz Forums 2000 v3.4.07
'##
'###############################################################################
'##
'## Copyright © 2000-09 Michael Anderson, Pierre Gorissen,
'## Huw Reddick and Richard Kinser
'##
'## This program is free. You can redistribute and/or modify it under the
'## terms of the GNU General Public License as published by the Free Software
'## Foundation; either version 2 or (at your option) any later version. '##
'## All copyright notices regarding Snitz Forums 2000 must remain intact in
'## the scripts and in the HTML output. The "powered by" text/logo with a
'## link back to http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet. '##
'## This program is distributed in the hope that it will be useful but
'## WITHOUT ANY WARRANTY; without even an implied warranty of MERCHANTABILITY
'## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
'## for more details. '##
'## You should have received a copy of the GNU General Public License along
'## with this program; if not, write to:
'##
'## Free Software Foundation, Inc. '## 59 Temple Place, Suite 330
'## Boston, MA 02111-1307
'##
'## Support can be obtained from our support forums at:
'##
'## http://forum.snitz.com
'##
'## Correspondence and marketing questions can be sent to:
'##
'## manderson@snitz.com
'##
'###############################################################################
'##
'## Based on Kyodai's CountXViews
'##
'###############################################################################
%>
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_header.asp" -->
<%
If mLev > 1 Then
Response.Write "<table border=""0"" width=""100%"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td width=""33%"" align=""left"" nowrap><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" " & getCurrentIcon(strIconFolderOpen,"","") & " <a href=""default.asp"">All Forums</a><br />" & vbNewLine & _
" " & getCurrentIcon(strIconBlank,"","") & getCurrentIcon(strIconBar,"","") & getCurrentIcon(strIconFolderOpenTopic,"","") & " Topic Activity<br /></font></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
"</table><br>" & vbNewLine
intPeriod = 30
If Request.Form("Duration")<>"30" Then
intPeriod = 7
end if
datActivityDays = DateAdd("d", -intPeriod, Date())
myActivityDate = DateToStr(datActivityDays)
Response.Write "<table align=""center"" width=""100%"" bgColor=""" & strTableBorderColor & """ style=""border-collapse:collapse"" cellpadding=""4"" cellspacing=""1"" border=""1"">" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td colspan=""4"" align=""center"" width=""100%"" bgColor=""" & strPopupTableColor & """>" & vbNewLine & _
" <form action=""Counts.asp"" method=""post"">" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strCategoryFontColor & """ size=""" & strHeaderFontSize+2 & """>Activity Monitor<br><small>(Most Viewed Topics in Past " & _
" <input type=""radio"" class=""radio"" name=""Duration"" value=""30""" & chkRadio(intPeriod,30,true) & ">30" & _
" <input type=""radio"" class=""radio"" name=""Duration"" value=""7""" & chkRadio(intPeriod,7,true) & ">7 Days)</small>" & _
" <input type=""submit"" name=""Submit"" value=""Submit"">" & _
" </font>" & _
" </form>" & _
" </td>" & _
" </tr></table><br>" & _
"<table align=""center"" width=""100%"" bgColor=""" & strTableBorderColor & """ style=""border-collapse:collapse"" cellpadding=""4"" cellspacing=""1"" border=""1"">" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td align=""center"" width=""10%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>VIEWS</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""15%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>AUTHOR</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""5%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>TOPIC</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""70%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>SUBJECT</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine
Set rsTopic = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT TOP 5 T_VIEW_COUNT, T_SUBJECT, T_AUTHOR, TOPIC_ID FROM " & strTablePrefix & "TOPICS WHERE T_DATE > '" & myActivityDate & "' ORDER BY T_VIEW_COUNT DESC"
rsTopic.Open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
If rsTopic.EOF Then
Response.Write "<tr><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """>None Viewed</td></tr>"
Else
il=0
im=0
rsTopic.MoveFirst
Do while NOT rsTopic.EOF
CColor = strForumCellColor
if il<>0 then CColor = strForumFirstCellColor
Response.Write "<font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strForumFontColor & """>" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td align=""center"" width=""10%"" bgColor=" & CColor & ">" & vbNewLine & _
rsTopic("T_VIEW_COUNT") & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""15%"" bgColor=" & CColor & ">"
If strUseExtEndedProfile Then
Response.Write "<a href=""pop_profile.asp?mode=display&id="& rsTopic("T_AUTHOR") & """>"
Else
Response.Write "<a href=""JavaScript:openWindow2('pop_profile.asp?mode=display&id=" & rsTopic("T_AUTHOR") & "')"">"
End If
Response.Write GetMemberName(rsTopic("T_AUTHOR")) & "</a>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""5%"" bgColor=" & CColor & ">" & vbNewLine & _
" <a href=""topic.asp?TOPIC_ID=" & rsTopic("TOPIC_ID") &""">" & rsTopic("TOPIC_ID") & "</a>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""left"" width=""70%"" bgColor=" & CColor & ">" & vbNewLine & _
rsTopic("T_SUBJECT") & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </font>" & vbNewLine
il=1-il
im=im+1
if im=5 then exit do
rsTopic.MoveNext
Loop
rsTopic.Close
End If
Set rsTopic = Nothing
Response.Write " </table><br><table align=""center"" width=""100%"" bgColor=""" & strTableBorderColor & """ style=""border-collapse:collapse"" cellpadding=""4"" cellspacing=""1"" border=""1"">" & vbNewLine & _
" <td align=""center"" width=""10%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>REPLIES</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""15%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>AUTHOR</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""5%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>TOPIC</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""70%"" bgColor=""" & strHeadCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize+1 & """><b>SUBJECT</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine
Set rsTopic = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT TOP 5 T_REPLIES, T_SUBJECT, T_AUTHOR, TOPIC_ID FROM " & strTablePrefix & "TOPICS WHERE T_DATE > '" & myActivityDate & "' ORDER BY T_REPLIES DESC"
rsTopic.Open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
If rsTopic.EOF Then
Response.Write "<tr><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """> </td><td bgColor=""" & strForumCellColor & """>No Replies</td></tr>"
Else
il=0
im=0
rsTopic.MoveFirst
Do while NOT rsTopic.EOF
CColor = strForumCellColor
if il<>0 then CColor = strForumFirstCellColor
Response.Write "<font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strForumFontColor & """>" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td align=""center"" width=""10%"" bgColor=" & CColor & ">" & vbNewLine & _
rsTopic("T_REPLIES") & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""15%"" bgColor=" & CColor & ">"
If strUseExtEndedProfile Then
Response.Write "<a href=""pop_profile.asp?mode=display&id="& rsTopic("T_AUTHOR") & """>"
Else
Response.Write "<a href=""JavaScript:openWindow2('pop_profile.asp?mode=display&id=" & rsTopic("T_AUTHOR") & "')"">"
End If
Response.Write GetMemberName(rsTopic("T_AUTHOR")) & "</a>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""center"" width=""5%"" bgColor=" & CColor & ">" & vbNewLine & _
" <a href=""topic.asp?TOPIC_ID=" & rsTopic("TOPIC_ID") &""">" & rsTopic("TOPIC_ID") & "</a>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""left"" width=""70%"" bgColor=" & CColor & ">" & vbNewLine & _
rsTopic("T_SUBJECT") & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </font>" & vbNewLine
il=1-il
im=im+1
if im=5 then exit do
rsTopic.MoveNext
Loop
rsTopic.Close
End If
Set rsTopic = Nothing
Response.Write "</table>"
Else
Response.Write "<center>Unauthorized access.<br><br></center>" & vbNewLine & _
" <meta http-equiv=""Refresh"" content=""2; URL=default.asp"">" & vbNewLine
End If
WriteFooter
%>
نوشته شده در
New Member
kyodai
مطلب: 74
74
Whoa good work. Very clean code and awesome structure. Thumbs up!!! =)
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
Thanks. Glad you like it. I made one small change, turned the topic authors into hyperlinks. Now you can replace four programs with the one.
نوشته شده در
Retired Support Moderator
MarcelG
مطلب: 2625
2625
Ehm, just curious. What does this actually show? Does this show the topics that have had the most views *in the last 7 or 30 days* or does this show the active topics of *the last 7 or 30 days* ordered by viewcount? Because as far as I can recall we register the viewcount as 1 single value with each topic, not as views of that topic by day. So a topic with a viewcount of 10000 on 1-1-2011 will show up in this report with a 10001 views even if the only activity is 1 post and 1 view on february 1st 2011. A topic with a viewcount of 0 on 1-1-2001 but with 1000 views on february 1st 2011 will show up as less viewed in the last 30 days, but it has received 1000x as many views as the first topic.
The only way of finding out the number of views in the last n days is by registering those views per day. Without that data, there isn't anything you can analyze.
نوشته شده در
Forum Admin
HuwR
مطلب: 20611
20611
from looking at the code, it shows topics created within the last 7-30 days ordered by their viewcount
نوشته شده در
New Member
kyodai
مطلب: 74
74
Yeah i made it "Topics created" as we have some long running threads with like over 100,000 views that would have made the statistic very "static" so i wanted it rather to be only thread newly created in the past 30/7 days to reflect an idea of "What's hot" and what made most people curious. Instead of limiting by T_DATE you could also limit by T_LAST_POST if you want to display the top 5 most replied to posts that had a reply in the last 30 days. Of course this would also include replies that were made long ago, so its rather the "top 5 still alive" threads on my forums.
 
شما باید یک متن وارد کنید