Thanks Mod Revisited

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/70454?pagenum=1
05 November 2025, 12:23

Topic


Carefree
Thanks Mod Revisited
11 March 2013, 12:20


This has come up a number of times over the years and, as far as I know, nobody has done it. I'd be happy to code it but I'm hitting a mental block as to the best way. Anyone have any suggestions?

 

Replies ...


ruirib
11 March 2013, 13:21


Not sure I understand what you want suggestions about. How it should work for users? How to keep the data related to it? How to actually code it?
Carefree
11 March 2013, 16:04


More on the database integration. Considering how best to record all the users' thanks * thousands of posts. Maybe adding a memo field to the topic table and comma-separating the member_id numbers.....
ruirib
11 March 2013, 17:23


Definitely not adding stuff to the topics table. It's already way too big. Also, adding "unlimited" size text fields is not good, performance wise, in SQL Server databases. To me, I would say it's pretty clear:

Thanks table, with topic_ID, member_ID, date thanked. Thanks count, different topics count, added to the member's table (which is very "wide" too, anyway, but two integer fields are not a big source of trouble).
Webbo
11 March 2013, 18:02


Have you had a look at the Invision Power Service forum software. In the latest versions a member can Vote a post up if they think it is worth of a point, a bit like thanking the poster, and alongside the post there is a count to show if it has been voted up, the default being '0'

A member can be limited to a number of votes per day therefore only allowing them to vote on a predetermined number of times in a set period and only once per post to prevent abuse

It might be worth a look as a starting point smile
Davio
11 March 2013, 18:46


Originally posted by ruirib
Thanks table, with topic_ID, member_ID, date thanked. Thanks count, different topics count, added to the member's table (which is very big too, anyway, but two integer fields are not a big source of trouble.
That's the way I would go too.
bobby131313
11 March 2013, 22:21


I think this would be a nice addition to my forum. Been thinking about it for a while. I've seen 2 different versions on other forums. One where each member's name that thanked is under the post in a smaller font, and one where is says something like "This poster has been thanked XX times."
ruirib
12 March 2013, 04:01


VBulletin offers both, Bobby, and I really like the way VBulletin does it.
Carefree
12 March 2013, 05:49


Originally posted by ruirib Thanks table, with topic_ID, member_ID, date thanked. Thanks count, different topics count....
What would you use the two member table fields for? Wouldn't a query against the thanks/topic/member table give you any of the values or totals?
Also, what purpose for the date thanked? I've yet to see a thanks mod which reflects a date and not sure why someone would care.
ruirib
12 March 2013, 12:42


My proposal is based on VBulletin. I do like the date, which is shown near the thanks, which is itself shown near the post. This will allow you to know when the thanks was given.

The two fields will simply make it easy to obtain the value without excessive querying. VBulletin shows the number of thanks near each post, and if you don't have the values already calculated, you will have a lot of querying. Makes no sense to me. After, it's the same reason why we keep the post count for each user, instead of totalling it over a user's posts.
Carefree
12 March 2013, 14:07


OK. I'll take a look at their features, see what else I may incorporate into this project.
golfmann
16 March 2013, 12:03


An option to change from thanks to "like" would be nice.... I get calls for it all the time, but I'll take a working thanks and mod it if necessary... blush
golfmann
16 March 2013, 12:04


PS:
© 2000-2012 Snitz™ Communications

It's 2013
Giumer
24 March 2013, 06:04


Carefree have neuws for this proget ? thx
Carefree
24 March 2013, 07:48


I'm working on it, a bit at a time. Can't seem to concentrate on this one LOL.
bobby131313
24 March 2013, 09:57


You wanna here something funny? Even though I've been thinking about this mod for years, I've never actually had anyone take the time to ask for it. Then a few days after I post in this topic, I get this...
Is it possible to gets a 'thanks' button? Many times posters leave useful or insightful posts but I don't wish to clutter the topic threads by just saying thanks, I'm sure others also do feel this way too, but I'd like the poster to know that his/her post was appreciated as well as read.

Creepy...
MaGraham
29 March 2013, 23:15




This just sounds super exciting! cool
I especially like the thought of an option to change from "thanks" to "like" with this! bigsmile

Giumer
12 April 2013, 05:11


anyone have solotuion ?
Carefree
12 April 2013, 11:49


Working on it, Giumer. Taking longer than I thought it would, keep interrupting myself with other short-termed projects.
Giumer
12 April 2013, 12:04


ok mate thx !
golfmann
08 May 2013, 10:34


Any "luck" ?
If you ever get it I say we name it the Carefree Thanks Mod smile
Carefree
09 May 2013, 22:05


I'll finish it sooner or later. I suppose I should try and concentrate on it more. Don't know what it is about this one, I work on it a few minutes and do almost anything else to get away.
golfmann
09 May 2013, 22:47


If I can help beta test or something, let me know. I am sure others are willing to pitch in as well.
You're not alone, ya' know... smile
AnonJr
10 May 2013, 08:49


Originally posted by Carefree
I'll finish it sooner or later. I suppose I should try and concentrate on it more. Don't know what it is about this one, I work on it a few minutes and do almost anything else to get away.
I've got a project or two like that myself. blush
Giumer
03 October 2013, 22:37


Carefree mate have news for this mod ?
Carefree
06 March 2015, 07:06


I had forgotten this project. I'm really good at forgetting now. At any rate, I finished this idea before I forgot about it. This allows all members to express "Thanks" for a topic/reply, only once each. Members cannot "Thank" their own post. It displays the count beside the icon. I chose NOT to have it display names of thanking users. The link is disabled if not a member or if a member has already "Thanked" a topic/reply. There is also prevention to preclude someone creating the link for an automatic script.
Get an updated copy on SnitzBitz or follow instructions below.
Super easy to install, maybe a 1 out of 10.
1. Save the following as "dbs_thanks.asp" in your forum folder, run it from the admin console.
Code:

Thanks 1.0
[CREATE] THANKS

TOPIC_ID#INT##0
REPLY_ID#INT##0
MEMBER_ID#INT##0
[END]

2. Modify the following two files as indicated:

"inc_iconfiles.asp"
Code:

Look for the following line (appx 148):

Const strIconZap = "icon_zap.gif|16|16"

Below it, insert this:

Const strIconThanks = "icon_thanks.png|23|22"

"topic.asp"
Code:

Look for the following lines (appx 842-844):

Response.Write " <hr noshade size=""" & strFooterFontSize & """></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <tr>" & vbNewLine & _

Above those, insert these:

' ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TOPIC_ID") & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID = 0"
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And (TMember_ID <> MemberID) And (mLev > 0) Then
If (Request("Thanks") > "") And (Request("REPLY_ID")<1) Then
my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ")")
End If
Else
intTY=1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE REPLY_ID=0 AND TOPIC_ID=" & TOPIC_ID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (TMember_ID <> MemberID) And (intTY = 0) And (mLev > 0) Then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&TOPIC_ID=" & Topic_ID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """>" & intCnt & "</font>" & vbNewLine
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """>" & intCnt & "</font>" & vbNewLine
End If
' ## Thanks Above

Next, look for the following lines (appx 641-643):

Response.Write " <hr noshade size=""" & strFooterFontSize & """></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <tr>" & vbNewLine & _


Above those, insert these:

' ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And (Reply_MemberID <> MemberID) And (mLev > 0) Then
If Request("Thanks") > "" Then
my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID, REPLY_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ", " & ChkString(Request("REPLY_ID"), "SQLString") & ")")
End If
Else
intTY = 1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (Reply_MemberID <> MemberID) And (intTY = 0) And (mLev > 0) Then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&REPLY_ID=" & Reply_ReplyID & "&TOPIC_ID=" & Reply_TopicID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """>" & intCnt & "</font>" & vbNewLine
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """>" & intCnt & "</font>" & vbNewLine
End If
' ## Thanks Above


3. Finally, save the following image (or make your own) in your images folder, titled "icon_thanks.png".

To display names in a popup, here's what you need:

Use this code INSTEAD of the one above for "topic.asp"
Code:

Look for the following lines (appx 842-844):

Response.Write " <hr noshade size=""" & strFooterFontSize & """></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <tr>" & vbNewLine & _

Above those, insert these:

' ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TOPIC_ID") & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID = 0"
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And (TMember_ID <> MemberID) And (mLev > 0) Then
If (Request("Thanks") > "") And (Request("REPLY_ID")<1) Then
my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ")")
End If
Else
intTY=1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE REPLY_ID=0 AND TOPIC_ID=" & TOPIC_ID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (TMember_ID <> MemberID) And (intTY = 0) And (mLev > 0) Then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&TOPIC_ID=" & Topic_ID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Topic_ID & "&RID=0')"">" & intCnt & "</a></font>" & vbNewLine
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Topic_ID & "&RID=0')"">" & intCnt & "</a></font>" & vbNewLine
End If
' ## Thanks Above

Next, look for the following lines (appx 641-643):

Response.Write " <hr noshade size=""" & strFooterFontSize & """></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <tr>" & vbNewLine & _


Above those, insert these:

' ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And (Reply_MemberID <> MemberID) And (mLev > 0) Then
If Request("Thanks") > "" Then
my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID, REPLY_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ", " & ChkString(Request("REPLY_ID"), "SQLString") & ")")
End If
Else
intTY = 1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (Reply_MemberID <> MemberID) And (intTY = 0) And (mLev > 0) Then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&REPLY_ID=" & Reply_ReplyID & "&TOPIC_ID=" & Reply_TopicID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
End If
' ## Thanks Above

"inc_header.asp"
Code:

Look for the following lines (appx 256-258):

"function openWindowHelp(url) {" & vbNewLine & _
" popupWin = window.open(url,'new_page','width=470,height=200,scrollbars=yes')" & vbNewLine & _
"}" & vbNewLine & _

Below those, insert these:

"function openWindowThanks(url) {" & vbNewLine & _
" popupWin = window.open(url,'new_page','width=800,height=600,scrollbars=yes,resizable=yes')" & vbNewLine & _
"}" & vbNewLine & _

Save the following as "pop_thanks.asp". Set the value on line 11 to who you wish to allow to view.
Code:

<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_header_short.asp" -->
<%
' ## Set value for intTYReaders below. ' 0 = Author only
' 1 = Author, Admins
' 2 = Author, Admins, Moderators
' 3 = All members
' 4 = Anyone

intTYReaders = 0 : intTYAllowed=0
If Request("RID") > "0" Then
strSqlTY = "SELECT R_AUTHOR FROM " & strTablePrefix & "REPLY WHERE REPLY_ID=" & Request("RID")
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intRID=rsTY("R_AUTHOR")
rsTY.Close
End If
Set rsTY = Nothing
Select Case intTYReaders
Case 0
If (MemberID = intRID) Then
Call TY_Replies
End If
Case 1
If (MemberID = intRID) Or (mLev > 2) Then
Call TY_Replies
End If
Case 2
If (MemberID = intRID) Or (mLev > 1) Then
Call TY_Replies
End If
Case 3
If (MemberID = intRID) Or (mLev > 0) Then
Call TY_Replies
End If
Case Else
Call TY_Replies
End Select
End If
If Request("RID") = "0" Then
strSqlTY = "SELECT T_AUTHOR FROM " & strTablePrefix & "TOPICS WHERE TOPIC_ID=" & Request("TID") & " AND REPLY_ID=0)
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intTID=rsTY("T_AUTHOR")
rsTY.Close
End If
Set rsTY = Nothing
Select Case intTYReaders
Case 0
If (MemberID = intTID) Then
Call TY_Topics
End If
Case 1
If (MemberID = intTID) Or (mLev > 2) Then
Call TY_Topics
End If
Case 2
If (MemberID = intTID) Or (mLev > 1) Then
Call TY_Topics
End If
Case 3
If (MemberID = intTID) Or (mLev > 0) Then
Call TY_Topics
End If
Case Else
Call TY_Topics
End Select
End If

Sub TY_Replies
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TID") & " AND REPLY_ID=" & Request("RID")
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
rsTY.MoveFirst
Do While Not rsTY.EOF
strSqlTYM = "SELECT M_NAME FROM " & strMemberTablePrefix & "MEMBERS WHERE MEMBER_ID = " & rsTY("MEMBER_ID")
Set rsTYM=my_Conn.Execute(strSqlTYM)
If Not rsTYM.EOF Then
Response.Write rsTYM("M_NAME")
rsTYM.Close
End If
Set rsTYM = Nothing
rsTY.MoveNext
If Not rsTY.EOF Then Response.Write ", "
Loop
rsTY.Close
End If
Set rsTY=Nothing
intTYAllowed=1
End Sub

Sub TY_Topics
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TID")
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
rsTY.MoveFirst
Do While Not rsTY.EOF
strSqlTYM = "SELECT M_NAME FROM " & strMemberTablePrefix & "MEMBERS WHERE MEMBER_ID = " & rsTY("MEMBER_ID")
Set rsTYM=my_Conn.Execute(strSqlTYM)
If Not rsTYM.EOF Then
Response.Write rsTYM("M_NAME")
rsTYM.Close
End If
Set rsTYM = Nothing
rsTY.MoveNext
If Not rsTY.EOF Then Response.Write ", "
Loop
rsTY.Close
End If
Set rsTY=Nothing
intTYAllowed=1
End Sub
If intTYAllowed = 0 Then Response.Write "Not authorized to view names.<br />"
WriteFooterShort
%>
Classicmotorcycling
07 March 2015, 18:43


Hi Carefree,

I hope that you do not mind, but I did a slight change to stop non-members/not signed in members from clicking the thanks button as I got a few robots clicking the links shortly after putting it up.
Small change to iconfiles.asp:
Code:

Code:

Look for the following line (appx 148):

Const strIconZap = "icon_zap.gif|16|16"

Below it, insert this:

Const strIconThanks = "icon_thanks.png|16|16"

Small change to topic.asp:
Code:

Code:


Look for the following lines (appx 842-844):

Response.Write " <hr noshade size=""" & strFooterFontSize & """></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <tr>" & vbNewLine & _

Above those, insert these:

' ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TOPIC_ID") & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID = 0"
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And TMember_ID <> MemberID Then
If Request("Thanks") > "" Then
my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ")")
End If
Else
intTY=1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE REPLY_ID=0 AND TOPIC_ID=" & TOPIC_ID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (TMember_ID <> MemberID) And (intTY = 0) Then
if mlev > 0 then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&TOPIC_ID=" & Topic_ID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>(" & intCnt & ")</font>" & vbNewLine
else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>(" & intCnt & ")</font>" & vbNewLine
end if
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>(" & intCnt & ")</font>" & vbNewLine
End If
' ## Thanks Above

Next, look for the following lines (appx 641-643):

Response.Write " <hr noshade size=""" & strFooterFontSize & """></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <tr>" & vbNewLine & _

Above those, insert these:

' ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And (Reply_MemberID <> MemberID) Then
If Request("Thanks") > "" Then
my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID, REPLY_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ", " & ChkString(Request("REPLY_ID"), "SQLString") & ")")
End If
Else
intTY = 1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (Reply_MemberID <> MemberID) And (intTY = 0) Then
if mlev > 0 then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&REPLY_ID=" & Reply_ReplyID & "&TOPIC_ID=" & Reply_TopicID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>(" & intCnt & ")</font>" & vbNewLine
else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>(" & intCnt & ")</font>" & vbNewLine
end if
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>(" & intCnt & ")</font>" & vbNewLine
End If
' ## Thanks Above


I also created a new icon if that is OK:


I kinda went like the Farcebook like icon, but the other way and darker.
Carefree
07 March 2015, 20:33


I incorporated anti-spammer/anti-hacker into the previous post now. Didn't think about bots before, thanks. You need to do one additional step, though, to prevent an automatic script from adding to the count - look at my code.
As for the icon and sizing, that's entirely up to you, it doesn't affect performance.
golfmann
08 March 2015, 14:42


I'd really like to have the members who thanked pop up upon hovering on the number. Would that be too much of a problem to do?
(hopefully not) smile
Carefree
08 March 2015, 19:16


See previous page for instructions on displaying names.
Webbo
10 March 2015, 02:36


I got the following error message when running the dbs file...
Creating table(s)... CREATE TABLE FORUM_THANKS( THANKS_ID INT (11) DEFAULT '' NOT NULL auto_increment , TOPIC_ID int NOT NULL DEFAULT 0, REPLY_ID int NOT NULL DEFAULT 0, MEMBER_ID int NOT NULL DEFAULT 0,KEY FORUM_THANKS_THANKS_ID(THANKS_ID))
CREATE TABLE FORUM_THANKS( THANKS_ID INT (11) DEFAULT '' NOT NULL auto_increment , TOPIC_ID int NOT NULL DEFAULT 0, REPLY_ID int NOT NULL DEFAULT 0, MEMBER_ID int NOT NULL DEFAULT 0,KEY FORUM_THANKS_THANKS_ID(THANKS_ID))
-2147467259 | [MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]Invalid default value for 'THANKS_ID'

Carefree
10 March 2015, 04:40


It's actually not needed. Leave a blank line where the Thanks_ID is. I was going to use it for a future change, but go without it.
Webbo
10 March 2015, 15:19


I've installed it but get the following error in a reply after the opening post after someone 'thanks' the first post.....
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]Table 'database_name.reply' doesn't exist

/forum/pop_thanks.asp, line 14

It's a MySql databse if that helps at all
Carefree
10 March 2015, 18:51


Also when clicking to see who has 'thanked' the pop up returns the following error..
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]Table 'database_name.reply' doesn't exist
That's because you never configured your strActivePrefix in config.asp ... a lot of the code uses that and you're going to run into errors until you add it. But for the purpose of this, I'll change it to strTablePrefix and the error will go away.
There was one other tiny error in "pop_thanks.asp" having to do with counting the topic "thanks". I had neglected to exclude replies. All code has been fixed on the post and on SnitzBitz.
Webbo
11 March 2015, 02:35


Still can't seem to get rid of the error message...
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

/forum/topic.asp, line 946

Here's a link to my topic.asp (.txt) with the changes implemented it you wish to take a look: topic.txt
Carefree
11 March 2015, 04:36


The lines surrounding 946 in this file:

[scrollcode] '## Ignore Post mod
if strIgnorePost = "1" then
boolIgnoreReply = ChkIgnoreList(arrIgnoreMemberList, Reply_MemberID)
end if
[/code]
The word "thanks" does not appear. I don't think this is the right file.....
Webbo
11 March 2015, 13:42


My mistake, please try again, both pieces of code start at lines 940 and 1380
Carefree
11 March 2015, 16:24


It should work fine the way it is, but it's misbehaving. Replace that block of code with this, maybe MySQL will not hiccup.
Code:

         '  ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And (Reply_MemberID <> MemberID) And (mLev > 0) Then
If Request("Thanks") > "" Then
intTID=ChkString(Request("TOPIC_ID"), "SQLString")
intRID=ChkString(Request("REPLY_ID"), "SQLString")
strSqlTY = "INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID, REPLY_ID) VALUES (" & MemberID & ", " & intTID & ", " & intRID & ")"
my_Conn.Execute(strSqlTY)
End If
Else
intTY = 1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (Reply_MemberID <> MemberID) And (intTY = 0) And (mLev > 0) Then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&REPLY_ID=" & Reply_ReplyID & "&TOPIC_ID=" & Reply_TopicID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
End If
' ## Thanks Above
Webbo
11 March 2015, 16:41


Replacing the first block of code resulted in the following error...
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

/forum/topic.asp, line 948

Replacing both blocks of code with the same caused the thread not to display and the initial post to be replaced with an error
Carefree
11 March 2015, 17:23


The code isn't the same for both sections. One is for topics, the other for replies. This is the 940 block:

Code:

         '  ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And (Reply_MemberID <> MemberID) And (mLev > 0) Then
If Request("Thanks") > "" Then
my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID, REPLY_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ", " & ChkString(Request("REPLY_ID"), "SQLString") & ")")
End If
Else
intTY = 1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND REPLY_ID=" & Reply_ReplyID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (Reply_MemberID <> MemberID) And (intTY = 0) And (mLev > 0) Then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&REPLY_ID=" & Reply_ReplyID & "&TOPIC_ID=" & Reply_TopicID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
End If
' ## Thanks Above

This is the 1380 block:

Code:

   '  ## Thanks Below
intCnt = 0 : intTY = 0
strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TOPIC_ID") & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID = 0"
Set rsTY=my_Conn.Execute(strSqlTY)
If (rsTY.BOF Or rsTY.EOF) And (TMember_ID <> MemberID) And (mLev > 0) Then
If (Request("Thanks") > "") And (Request("REPLY_ID")<1) Then
my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ")")
End If
Else
intTY=1
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE REPLY_ID=0 AND TOPIC_ID=" & TOPIC_ID
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intCnt = rsTY("CNT")
rsTY.Close
End If
Set rsTY = Nothing
If (TMember_ID <> MemberID) And (intTY = 0) And (mLev > 0) Then
Response.Write " <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&TOPIC_ID=" & Topic_ID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Topic_ID & "&RID=0')"">" & intCnt & "</a></font>" & vbNewLine
Else
Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Topic_ID & "&RID=0')"">" & intCnt & "</a></font>" & vbNewLine
End If
' ## Thanks Above

When you thank the topic, do you get an error?
Carefree
11 March 2015, 17:25


Is anyone else running this on a MySQL database? If so, are you experiencing the errors that Webbo has?
Webbo
11 March 2015, 17:48


Okay,

starting with a new file and the changes above....
when thanking the initial post in the topic I get the following error in the first reply and no other replies show...
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

/forum/topic.asp, line 945



Emptying the table (thanks) to start again....
If I 'thank' the first reply in the thread it works

However if I 'thank' the initial post or subsequent replies, whilst they add 1 'thanks' to that it adds a further 4 thanks to the first reply also, and the table in the database looks like this...

smile
Carefree
11 March 2015, 20:31


You have a loop someplace. It definitely won't do that the way I wrote it. I tested this on a pristine (virgin) Snitz installation and it works perfectly. Look for something like this (surrounding the Thanks code).

Code:
For i = 1 to 4

or

Do while

or

Do until
Webbo
12 March 2015, 13:20


I thought I'd found the problem and that is with the way that the database was set up as MySql apparently doesn`t like Auto Increment unless the column is Primary

However changing the database table 'thanks' to add auto increment resulted in the following error and also the author of the post below the one I chose to 'thank' being thanked ....
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]Duplicate entry '180108' for key 'PRIMARY'

/forum/topic.asp, line 946


There are three instances where loops are created and they are within the 'Polls' mod code and the 'Active Users' mod code, line 182, 1107 and 1135
Carefree
12 March 2015, 19:57


You don't need to worry about the Thanks_ID. It's not necessary for the mod as it stands now. So auto-increment isn't a factor.
Carefree
03 April 2015, 06:10


Discovered that screen refreshing can cause thanks counter to increase, so modified code to use "select distinct". Get the update on SnitzBitz.
Carefree
03 April 2015, 10:18


OK. There's a SQL 'GROUP BY' syntax error on lines 20/50 (in red) below. It works fine with MS Access, but MS SQL gets the hiccups. Can anyone spot a problem?
Code:

<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_header_short.asp" -->
<%
' ## Set value for intReaders below. ' 0 = Author only
' 1 = Author, Admins
' 2 = Author, Admins, Moderators
' 3 = All members
' 4 = Anyone

intTYReaders = 1 : intTYAllowed=0
If Request("RID") > "0" Then
strSqlTY = "SELECT R_AUTHOR FROM " & strTablePrefix & "REPLY WHERE REPLY_ID=" & Request("RID")
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intRID=rsTY("R_AUTHOR")
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT MEMBER_ID FROM (SELECT DISTINCT MEMBER_ID, TOPIC_ID, REPLY_ID FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TID") & " AND REPLY_ID=" & Request("RID") & ") GROUP BY MEMBER_ID, TOPIC_ID, REPLY_ID;"
Select Case intTYReaders
Case 0
If (MemberID = intRID) Then
Call TYP
End If
Case 1
If (MemberID = intRID) Or (mLev > 2) Then
Call TYP
End If
Case 2
If (MemberID = intRID) Or (mLev > 1) Then
Call TYP
End If
Case 3
If (MemberID = intRID) Or (mLev > 0) Then
Call TYP
End If
Case Else
Call TYP
End Select
End If
If Request("RID") = "0" Then
strSqlTY = "SELECT T_AUTHOR FROM " & strTablePrefix & "TOPICS WHERE TOPIC_ID=" & Request("TID")
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
intTID=rsTY("T_AUTHOR")
rsTY.Close
End If
Set rsTY = Nothing
strSqlTY = "SELECT MEMBER_ID FROM (SELECT DISTINCT MEMBER_ID, TOPIC_ID, REPLY_ID FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TID") & " AND REPLY_ID=0) GROUP BY MEMBER_ID, TOPIC_ID, REPLY_ID;"
Select Case intTYReaders
Case 0
If (MemberID = intTID) Then
Call TYP
End If
Case 1
If (MemberID = intTID) Or (mLev > 2) Then
Call TYP
End If
Case 2
If (MemberID = intTID) Or (mLev > 1) Then
Call TYP
End If
Case 3
If (MemberID = intTID) Or (mLev > 0) Then
Call TYP
End If
Case Else
Call TYP
End Select
End If

Sub TYP
Set rsTY=my_Conn.Execute(strSqlTY)
If Not rsTY.EOF Then
Response.Write "<table align=""0"" border=""0"" cellpadding=""4"" cellspacing=""0"" bgColor=""" & strPageBGColor & """>" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine
rsTY.MoveFirst
intAvatDis=0
Do While Not rsTY.EOF
intAvatDis = intAvatDis + 1
If intAvatDis=5 Then
intAvatDis = 0
Response.Write "</tr><tr valign=""middle"">"
End If
Response.Write "<td align=""center"">"
strSqlTYM = "SELECT DISTINCT M_NAME FROM " & strMemberTablePrefix & "MEMBERS WHERE MEMBER_ID = " & rsTY("MEMBER_ID")
Set rsTYM=my_Conn.Execute(strSqlTYM)
If Not rsTYM.EOF Then
Response.Write profilelink(rsTYM("M_NAME"),rsTY("MEMBER_ID"))
rsTYM.Close
End If
Set rsTYM = Nothing
rsTY.MoveNext
If Not rsTY.EOF Then
Response.Write ", "
Else
Response.Write "</td>"
End If
Loop
rsTY.Close
End If
Set rsTY=Nothing
intTYAllowed=1
End Sub
%>
ruirib
03 April 2015, 13:15


In SQL Server, fields in a Group By clause need to be included in the SELECT clause, as well. There are some exceptions to this, but they don't apply to your case.
Carefree
03 April 2015, 16:57


Well, I previously only had group by member_id since that was the only selected field ... that didn't work, same error. So I guess I need to put all three fields in the first select as well as in the distinct select?
ruirib
03 April 2015, 17:44


Originally posted by Carefree
Well, I previously only had group by member_id since that was the only selected field ... that didn't work, same error. So I guess I need to put all three fields in the first select as well as in the distinct select?
Yes, you need to have all three fields in the SELECT clause.The fields are needed in the query that has the GROUP BY clause but here, since you are SELECT from the subquery, the subquery needs the three fields as well, or they wouldn't be in the main query, to start with.
With a single Group By field, and that field present in the SELECT clause, I don't see why the query would fail.
Carefree
03 April 2015, 22:51


Well, no change, still failed. Back to the drawing board.
Redid the routines in "topic.asp" and the "pop_thanks.asp" on SnitzBitz. They will now work with all.
Carefree
07 April 2015, 16:23


Heard that someone experienced an error. Please, either post a link to your "topic.asp" in .txt format for me to see, or reply here and surround your "topic.asp" with [scrollcode][/scrollcode].
Resolved. Had code blocks in wrong place.
© 2000-2021 Snitz™ Communications