Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 Poll Mod v2.0.8
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 3

SiSL
Average Member

Turkey
671 Posts

Posted - 30 April 2009 :  13:54:07  Show Profile  Visit SiSL's Homepage  Reply with Quote
POST.ASP

' ############################## Poll Mod ################################
	if Request.QueryString("poll") = "1" then
		'### Get poll from POLLS table
		strSql = "SELECT " & strTablePrefix & "POLLS.P_WHOVOTES "
		' CAREFUL FOR COMMAS
		'for i = 1 to 15
		'	strSql = strSql & strTablePrefix & "POLLS.ANSWER" & CStr(i) & ", "
		'	strSql = strSql & strTablePrefix & "POLLS.COUNT" & CStr(i)
		'	if i <> 15 then
		'		strSql = strSql & ", "
		'	end if
		'next
		strSql = strSql & " FROM " & strTablePrefix & "POLLS"
		strSql = strSql & " WHERE " & strTablePrefix & "POLLS.TOPIC_ID = " & strRqTopicID
		set rsPoll = my_Conn.Execute (strSql)
		
		if rsPoll.EOF or rsPoll.BOF then
			Go_Result "You are trying to edit a topic that is not a poll"
		else
			strWhoVotes = rsPoll("P_WHOVOTES")
			' I think I also removed something from here?
		end if
		rsPoll.Close
		set rsPoll = nothing
		
		strSql = "SELECT ANSWER_TEXT "
		strSql = strSql & " FROM " & strTablePrefix & "POLL_ANSWERS "
		strSql = strSql & " WHERE POLL_ID = " & strRqTopicID & " ORDER BY ANSWER_ORDER ASC"
		set rsPoll = my_Conn.Execute (strSql)
		
		if rsPoll.EOF or rsPoll.BOF then
			Go_Result "You are trying to edit a topic that is not a poll"
		else
			nTotal = 0
			ReDim txtAns(15)
			tumPollAnswers = rsPoll.GetRows
			For i=0 to UBound(tumPollAnswers,2)
				z = i+1
				txtAns(z) = tumPollAnswers(0,i)
				nTotal = nTotal + 1
			Next
			
			if CInt(strMaxVotes) > nTotal then
				nCount = strMaxVotes
			else
				nCount = nTotal
			end if
		end if
		rsPoll.Close
		set rsPoll = nothing
		
	end if
' ############################################################

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod

Edited by - SiSL on 30 April 2009 14:10:52
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 30 April 2009 :  13:56:38  Show Profile  Visit SiSL's Homepage  Reply with Quote
POST_INFO.asp

'############################ Poll Mod ##############################
		if Request.Form("poll") = "1" then
			strSql = "SELECT " & strTablePrefix & "TOPICS.TOPIC_ID "
			strSql = strSql & "FROM " & strTablePrefix & "TOPICS "
			strSql = strSql & "WHERE " & strTablePrefix & "TOPICS.T_ISPOLL = " & 1 & " "
			strSql = strSql & "ORDER BY " & strTablePrefix & "TOPICS.T_DATE DESC"
			set rsPollID = my_Conn.Execute (strSql)
			
			PollID = rsPollID("TOPIC_ID")
			
			rsPollID.close
			set rsPollID = nothing		
			
			'## Forum_SQL - Add new poll to Polls Table
			strSql = "INSERT INTO " & strTablePrefix & "POLLS (CAT_ID"
			strSql = strSql & ", FORUM_ID"
			strSql = strSql & ", TOPIC_ID"
			strSql = strSql & ", P_WHOVOTES"
			'for i = 1 to ubound(txtAns)
			'	strSql = strSql & ", ANSWER" & CStr(i)
			'	strSql = strSql & ", COUNT" & CStr(i)
			'next
			strSql = strSql & ") VALUES ("
			strSql = strSql & Cat_ID
			strSql = strSql & ", " & Forum_ID
			strSql = strSql & ", " & PollID
			strSql = strSql & ", '" & chkString(Request.Form("WhoVotes"),"SQLString") & "'"
			'for i = 1 to ubound(txtAns)
			'	strSql = strSql & ", '" & chkString(txtAns(i),"") & "'"
			'	strSql = strSql & ", " & 0
			'next
			strSql = strSql & ")"
			
			strSql = strSql & ""
			For i=1 to UBound(txtAns)
				if Trim(txtAns(i)) <> "" Then
					strSql = strSql & ";INSERT INTO " & strTablePrefix & "POLL_ANSWERS (POLL_ID, ANSWER_TEXT, ANSWER_ORDER, ANSWER_COUNT) VALUES ("
					strSql = strSql & PollID & ", '" &  chkString(txtAns(i),"SQLString") & "'," & i & ", " & 0 & ")"
				Else
					exit for
				End If
			next
			my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
		end if
   '####################################################################


Also in POST_INFO.ASP

'############################ Poll Mod ###################################
		if Request.Form("poll") = "1" then
			'### Update poll answers and counts
			strSql = "SELECT ANSWER_COUNT FROM " & strTablePrefix & "POLL_ANSWERS WHERE POLL_ID=" & Topic_ID & " ORDER BY ANSWER_ORDER ASC"
			set rs=my_Conn.Execute(strSql)
			if not rs.EOF Then
				tumPolls = rs.GetRows
				toplamPAnswers = UBound(tumPolls,2) + 1
			Else
				toplamPAnswers = 0
			End If
			rs.Close
			set rs=nothing
			
			strSql = "UPDATE " & strTablePrefix & "POLLS "
			strSql = strSql & " SET P_WHOVOTES = '" & chkString(Request.Form("WhoVotes"),"SQLString") & "', "
			strSql = strSql & " 		CAT_ID = " & cLng(aryForum(0)) & ", "
			strSql = strSql & "		FORUM_ID = " & cLng(aryForum(1)) & " "
			'for i = 1 to CInt(Request.Form("count"))
			'	strSql = strSql & "ANSWER" & CStr(i) & " = '" & chkString(txtAns(i),"") & "'"
			'	if txtAns(i) = "" or chkString(Request.Form("resetpoll"),"SQLString") = "1" then
			'		strSql = strSql & ", COUNT" & CStr(i) & " = " & 0
			'	end if
			'	if ubound(txtAns) <> i then
			'		strSql = strSql & ", "
			'	end if
			'next
			strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
			my_Conn.Execute(strSql),,adCmdText + adExecuteNoRecords
			
			strSQL = "DELETE FROM " & strTablePrefix & "POLL_ANSWERS WHERE POLL_ID = " & Topic_ID
			my_Conn.Execute(strSQL)
			strSQL = ""
			for i=1 to CInt(Request.Form("count"))
			if Trim(chkString(txtAns(i),"")) <> "" Then
				strSQL = strSQL & "INSERT INTO " & strTablePrefix & "POLL_ANSWERS (POLL_ID, ANSWER_TEXT, ANSWER_ORDER, ANSWER_COUNT) VALUES ("
				strSQL = strSQL & Topic_ID & ", "
				strSQL = strSQL & "'" & chkString(txtAns(i),"SQLString") & "', "
				strSQL = strSQL & i & ","
				if chkString(Request.Form("resetpoll"),"SQLString") = "1" then
					strSQL = strSQL & 0
				Else
					if i <= toplamPAnswers Then
						z = i-1
						strSQL = strSQL & tumPolls(0,z)
						
					Else
						strSQL = strSQL & 0
					End If	
				End If
			Else
				Exit for					
			End If
			strSql = strSql & ");"
			next
			
			my_Conn.Execute(strSql),,adCmdText + adExecuteNoRecords
			if Request.Form("resetpoll") = "1" then
				'### Delete poll votes from POLL_VOTES table for this topic
				strSql = "DELETE FROM " & strTablePrefix & "POLL_VOTES "
				strSql = strSql & "WHERE " & strTablePrefix & "POLL_VOTES.TOPIC_ID = " & Topic_ID
				my_Conn.Execute(strSql),,adCmdText + adExecuteNoRecords
			end if
		end if
	'#########################################################################




CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod

Edited by - SiSL on 30 April 2009 14:04:15
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 30 April 2009 :  13:59:49  Show Profile  Visit SiSL's Homepage  Reply with Quote
Okay, went through this, this might give an idea about it :) I showed in RED where I commented out

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 30 April 2009 :  14:00:01  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
ANSWER_ORDER should not be nullable.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 30 April 2009 :  14:01:07  Show Profile  Visit SiSL's Homepage  Reply with Quote
quote:
Originally posted by ruirib

ANSWER_ORDER should not be nullable.



Could be changed to that too :)

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 30 April 2009 :  14:07:18  Show Profile  Visit SiSL's Homepage  Reply with Quote
I think have to add good indexes to that too :P like my previous problem :)

PS: I'm such a mess code-writer, I guess it is like coding but not able to express what you did after :p Anarchic :)

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod

Edited by - SiSL on 30 April 2009 14:15:03
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 30 April 2009 :  18:01:02  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
Althought not needed, a clustered index for POLL_ID in table Polls won't hurt and then another clustered on for POLL_ID,Order in Answers. Don't think you will have that many polls, so this should be enough...


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000 Version 3.4.07