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)
 Database calls in Active.asp
 New Topic  Topic Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 6

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 24 March 2002 :  18:57:30  Show Profile  Visit Gremlin's Homepage
I'll bundle my changes up in to a Mod for a standard 3.3 forum over the next coupld of days for those of us who are going to be stuckon 3.3 for some time to come. It's certainly worth the effort of changing.

Right now I've left the changes as instr rathern than ubound becuase I think it works out a little more efficent. Whilst the string concatenation to create the string is a fairly 'expensive' task, so is ReDiming an array (which you may have to do multiple times to create the final array) and then you also need a small loop to check an ID against the array, so the instr code IMO has worked out probably a little cheaper.

Summary of changes

1) Placed new code at the top of getNewMemberNumber, and getMemberNumber and getMemberId

if MemberID <> 0 then
getNewMemberNumber = MemberID ' needs to change for each function
exit functio
end if

2) Created two new small functions in inc_functions to do my Instr work.

function fCanModerate(zForumId)
fCanModerate = 0
fCanModerate = instr(AllowForumModerate,"|" & zForumId & "|")
end function

function fAllowedForumAccess(zForumId)
fAllowedForumAccess = 0
fAllowedForumAccess = instr(AllowForumList,"|" & zForumId & "|")
end function

3) Updated chkForumModeator Procedure

function chkForumModerator(fMember_Name)
'## Forum_SQL
strSql = "SELECT mo.FORUM_ID "
strSql = strSql & " FROM " & strTablePrefix & "MODERATOR mo, " & strMemberTablePrefix & "MEMBERS me "
'strSql = strSql & " WHERE mo.FORUM_ID = " & fForum_ID & " "
strSql = strSql & " WHERE mo.MEMBER_ID = me.MEMBER_ID "

if strAuthType = "db" then
strSql = strSql & " AND me.M_NAME = '" & fMember_Name & "'"
elseif strAuthType = "nt" then
strSql = strSql & " AND me.M_USERNAME = '" & fMember_Name & "'"
end if

Set rsChk = Server.CreateObject("ADODB.Recordset")
rsChk.open strSql, my_Conn

if rsChk.bof or rsChk.eof then
y = ""
rsChk.Close()
set rsChk = nothing
else
ModeratorList = rsChk.GetRows()
rsChk.Close()
set rsChk = nothing

for RowCount = 0 to ubound(ModeratorList,2)
chkForumModerator = chkForumModerator & "|" & ModeratorList(0,RowCount)
next
chkForumModerator = chkForumModerator & "|" ' Add last Pipe to string.
end if

end function

4) Add one line to inc_top.asp to build pipe list

AllowForumModerate = chkForumModerator(MemberId) ' Pip Delimited list of Forums Member is Moderator of.

5) Replace every call to chkForumModerator with a call instead to fCanModerate (this is the biggest change about 15 different pages it occured in 50+ places in my modified forum) ie Lines 361 - 368 in active.asp (just the first example I picked) I changed from

if (mLev = 4) or _
((chkForumModerator(Forum_ID, Session(strCookieURL & "username"))= "1") and mLev = 3) or _
((chkForumModerator(Forum_ID, strDBNTUserName) = "1") and mlev = 3) or _
(lcase(strNoCookies) = "1") then
AdminAllowed = 1
else
AdminAllowed = 0
end if

To

if (mLev = 4) or ((fCanModerate(Forum_ID) = 1) and mLev = 3) or (lcase(strNoCookies) = "1") then
AdminAllowed = 1
else
AdminAllowed = 0
end if

6) Function isAllowedMember (inc_functions.asp) changed to

function isAllowedMember(fMemberID)
isAllowedMember = ""
on error resume next
strSql = "SELECT FORUM_ID FROM " & strTablePrefix & "ALLOWED_MEMBERS "
strSql = strSql & " WHERE " & strTablePrefix & "ALLOWED_MEMBERS.MEMBER_ID = " & ChkString(fMemberID, "SQLString")

Set rsAllowedMember = Server.CreateObject("ADODB.Recordset")
rsAllowedMember.open strSql, my_Conn
if not rsAllowedMember.EOF then
AllowedForums = rsAllowedMember.GetRows()
rsAllowedMember.Close()
set rsAllowedMember = nothing
For AllowCount = 0 to ubound(AllowedForums,2) ' Total Numer of Rows
isAllowedMember = isAllowedMember & "|" & AllowedForums(0,AllowCount)
next
isAllowedMember = isAllowedMember & "|" ' Add last pipe
end if

end function

7) New Line in inc_top.asp added

AllowForumList = isAllowedMember(MemberID) ' Pipe Delimited list of Forums Member has Access too

8) Did as for step 5 except this time changing all calls to IsAllowedMember and replacing them with calls to fAllowedForumAccess (I think most of those changes were all restricted to inc_functions.asp)
9) Function ChkForumAccess, removed the top part of the function

function chkForumAccess(fForum, UserNum)
chkForumAccess = false

strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.M_LEVEL "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS.MEMBER_ID=" & UserNum

Set rsCheck = Server.CreateObject("ADODB.Recordset")
rsCheck.open strSql, my_Conn

if rsCheck.BOF or rsCheck.EOF then
chkForumAccess = false
elseif rsCheck("M_LEVEL") = 3 then
chkForumAccess = true
rsCheck.close
set rsCheck = nothing
exit function
end if
rsCheck.close

'## Forum_SQL
strSql = "SELECT " & strTablePrefix & "FORUM.F_PRIVATEFORUMS, " & strTablePrefix & "FORUM.F_SUBJECT, " & strTablePrefix & "FORUM.F_PASSWORD_NEW "
strSql = strSql & " FROM " & strTablePrefix & "FORUM "
strSql = strSql & " WHERE " & strTablePrefix & "FORUM.Forum_ID = " & ChkString(fForum, "SQLString")

and Replaced with

function chkForumAccess(fForum, UserNum)
chkForumAccess = false

if mLev = 4 then
chkForumAccess = true
exit function
end if

'## Forum_SQL
strSql = "SELECT " & strTablePrefix & "FORUM.F_PRIVATEFORUMS, " & strTablePrefix & "FORUM.F_SUBJECT, " & strTablePrefix & "FORUM.F_PASSWORD_NEW "
strSql = strSql & " FROM " & strTablePrefix & "FORUM "
strSql = strSql & " WHERE " & strTablePrefix & "FORUM.Forum_ID = " & ChkString(fForum, "SQLString")

10) Converted active.asp to use GetRows(). I think if you just change the following it will work for you also. Lines 333 - 358 look like this

else
currForum = 0
fDisplayCount = 0
do until rs.EOF

'## Store all the recordvalues in variables first.

Forum_ID = rs("FORUM_ID")
Forum_Subject = rs("F_SUBJECT")
Topic_Status = rs("T_STATUS")
Topic_View_Count = rs("T_VIEW_COUNT")
Topic_ID = rs("TOPIC_ID")
Cat_ID = rs("CAT_ID")
Topic_Subject = rs("T_SUBJECT")
Topic_Author = rs("T_AUTHOR")
Topic_Replies = rs("T_REPLIES")
Member_Name = rs("M_NAME")
Topic_Last_Post_Author = rs("T_LAST_POST_AUTHOR")
Topic_Last_Post = rs("T_LAST_POST")
Topic_Last_Post_Author_Name = rs("LAST_POST_AUTHOR_NAME")
CatSubscription = rs("CAT_SUBSCRIPTION")
CatStatus = rs("CAT_STATUS")
ForumSubscription = rs("F_SUBSCRIPTION")
ForumStatus = rs("F_STATUS")

' Does user have access to the forum??

Replace them with

else
currForum = 0
fDisplayCount = 0
ActiveTopics = rs.GetRows()

fF_SUBJECT = 0
fF_SUBSCRIPTION = 1
fF_STATUS = 2
fF_ORDER = 3
fCAT_SUBSCRIPTION = 4
fCAT_STATUS = 5
fCAT_ORDER = 6
fT_STATUS = 7
fT_VIEW_COUNT = 8
fFORUM_ID = 9
fTOPIC_ID = 10
fCAT_ID = 11
fT_SUBJECT = 12
fT_AUTHOR = 13
fT_REPLIES = 14
fM_NAME = 15
fT_LAST_POST_AUTHOR = 16
fT_LAST_POST = 17
fLAST_POST_AUTHOR_NAME = 18


for RowCount = 0 to ubound(ActiveTopics,2)

'## Store all the recordvalues in variables first.

Forum_Subject = ActiveTopics(fF_SUBJECT,RowCount)
ForumSubscription = ActiveTopics(fF_SUBSCRIPTION,RowCount)
ForumStatus = ActiveTopics(fF_STATUS,RowCount)
Forum_Order = ActiveTopics(fF_ORDER,RowCount)
CatSubscription = ActiveTopics(fCAT_SUBSCRIPTION,RowCount)
CatStatus = ActiveTopics(fCAT_STATUS,RowCount)
CatOrder = ActiveTopics(fCAT_ORDER,RowCount)
Topic_Status = ActiveTopics(fT_STATUS,RowCount)
Topic_View_Count = ActiveTopics(fT_VIEW_COUNT,RowCount)
Forum_ID = ActiveTopics(fFORUM_ID,RowCount)
Topic_ID = ActiveTopics(fTOPIC_ID,RowCount)
Cat_ID = ActiveTopics(fCAT_ID,RowCount)
Topic_Subject = ActiveTopics(fT_SUBJECT,RowCount)
Topic_Author = ActiveTopics(fT_AUTHOR,RowCount)
Topic_Replies = ActiveTopics(fT_REPLIES,RowCount)
Member_Name = ActiveTopics(fM_NAME,RowCount)
Topic_Last_Post_Author = ActiveTopics(fT_LAST_POST_AUTHOR,RowCount)
Topic_Last_Post = ActiveTopics(fT_LAST_POST,RowCount)
Topic_Last_Post_Author_Name = ActiveTopics(fLAST_POST_AUTHOR_NAME,RowCount)


' Does user have access to the forum??

And Finally replace the rs.MoveNext on line 471 with Next

I "think" thats all the changes I made yesterday, please note I'm still testing that forum access etc still works and that I've not inadvertantly screwed something up and allowed people access to forums that are restricted. So far everything looks good.

I said at the start of this I'd bundle it up as a Mod, but I think this post pretty much covers it off well enough anyway so I won't.

I'll post any errors I encounter here, and if anyone else could do the same that would be appreciated. The clean may not be the best or purest way of doing things as I was really just working in a "proof of concept" mode to see what could be improved. However I'm personally satisfied enough with the savings in roundtrips to the DB that these changes will be going out on my live server as soon as I've finished testing them throughly.








www.daoc-halo.com
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 24 March 2002 :  19:20:19  Show Profile  Visit Aaron S.'s Homepage
Gremlin:

Are you planning on building a pipe delimited variable for Subscriptions too?

If not, I can take a stab, becuase that is where a lot of my performance problems will be coming from (I have moderation turned off).



Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 24 March 2002 :  19:22:26  Show Profile  Visit Nathan's Homepage
I had just started working on doing that Aaron, but if you want to do go for it!

  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 24 March 2002 :  19:23:57  Show Profile  Visit HuwR's Homepage
Ok then, I will just keep my mouth shut, and let you struggle on needlessly.

Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 24 March 2002 :  19:27:50  Show Profile  Visit Aaron S.'s Homepage
Huwr... I don't think it is needless because some of us will not be migrating to 3.4 immediately.

I have added a lot of MODs and custom code to the 3.3 version, so it will take me time to recreate some of that with the new version.

Plus, I think I'll wait a few weeks and let a lot of the bugs get shaken out first (and MODs converted over).



Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 24 March 2002 :  19:30:24  Show Profile  Visit Nathan's Homepage
That is, unless Huwr is hinting that he has a better method.

  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 24 March 2002 :  19:33:14  Show Profile  Visit Aaron S.'s Homepage
Nathan:

I am adding Gremlin's code now... and then will look at subscriptions.



Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 24 March 2002 :  19:36:51  Show Profile  Visit Nathan's Homepage
In that case I guess I'll work on my english paper

  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 24 March 2002 :  20:02:09  Show Profile  Visit Gremlin's Homepage
Wasn't planning on doing subs, so go for it.

Huw I'm probably never going to 3.4 so this is of great value, as I've mentioned before your not going to see a great deal of people just jump straight to 3.4 either as theres going to be a fair bit of time required for all Mods to be rewritten, or at a minimum the installation instructions to be rewritten as theres probably not a single line number left thats common between 3.3 and 3.4 (might want to reconsider calling it a point release, kind of implies not a lot has changed whereas as from what you and Richard have said thats completely the opposite).

I'll go to a hybrid 3.4 in time but thats becuase I'll just be taking the bits I need out of 3.4 and put them into 3.3, my 3.3's are already completely CSS so thats not likely to be needed for me personally either which I believe may be planned for a future release. I suspect when 3.4 comes out I'll not be around here much either.

www.daoc-halo.com



Edited by - Gremlin on 24 March 2002 20:05:26
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 24 March 2002 :  20:08:37  Show Profile  Visit HuwR's Homepage
quote:

Huw I'm probably never going to 3.4 so this is of great value, as I've mentioned before your not going to see a great deal of people just jump straight to 3.4 either as theres going to be a fair bit of


Funny, Iused this very same argument as the reason for releasing 3.4 before going full international on 4, and was accused of being Anti the international version.
quote:

I'll go to a hybrid 3.4 in time but thats becuase I'll just be taking the bits I need out of 3.4 and put them into 3.3, my 3.3's are


Not very likely, 3.3 and 3.4 are radically different, you will find it difficult to hybridise the two, and will save yourself a lot oftime by sarting from scratch.

The biggest benefits of 3.4 are security, it uses password encryption, and some security loop holes have been fixed.

Plus finally, the intention of the Dev discussion forum is to discuss the development of Snitz, not your personal mods.

Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 24 March 2002 :  20:13:24  Show Profile  Visit Gremlin's Homepage
I've got 500+ hours invested in modifications to 3.3, in some areas you wouldn't even recognise it was 3.3, I don't think its going to be quicker for me to make those changes to 3.4 seeing as I'll need to come up to speed with its code for starters.

www.daoc-halo.com
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 24 March 2002 :  20:15:28  Show Profile  Visit Gremlin's Homepage
quote:
The biggest benefits of 3.4 are security, it uses password encryption, and some security loop holes have been fixed.
which is the one area I've already decided on anaylsing in 3.4 and looking at ways to implement into my 3.3.

www.daoc-halo.com
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 24 March 2002 :  20:21:45  Show Profile  Visit HuwR's Homepage
quote:

I've got 500+ hours invested in modifications to 3.3, in some areas you wouldn't even recognise it was 3.3, I don't think its going to be quicker for me to make those changes to 3.4 seeing as I'll need to come up to speed with its code for starters.

www.daoc-halo.com



Obviously, you know better.

Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 24 March 2002 :  20:34:32  Show Profile  Visit Gremlin's Homepage
I'm not just sure how to take your comments Huw in the absence of any emoticon I'll assume sarcasim.

If I've offended you in anyway then I'm sorry, I'm sure you guys are making 3.4 absolutely fantastic.

If you would be a little more forthcomming in both releasing code and in consulting the general population on what they would like to see in the upcomming release and accepting some constructive critisim on the project it could see far greater potential than it does today, Doug, Richard and yourself appear to be great people and exceptionally good coders, but surely the 'minds' of a few extra 20-30 people adding to that "collective" could make Snitz better still.

Perhaps then things wouldn't come down to us trying to second guess what improvements you've made. Instead of waiting to find out I chose to go out and fix something that was actually a pretty serious concern as far as server resource was concerned, possibly even the cause of why some people have had their hosts kick them off for using Snitz. If you've had fixes for this for sometime, then why on earth haven't you released them to the public ?

Again I'm sorry If I've offended anyone here, I feel strongly about Snitz and equally so about my own opinions and the efforts I've put into making my version feel like something I can be proud of.

www.daoc-halo.com


Edited by - Gremlin on 24 March 2002 20:37:04
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 24 March 2002 :  20:43:08  Show Profile  Visit HuwR's Homepage
I started optimising the functions include files and some queeries only a few days ago, which is why I made the posts in this thread to make you aware that all this stuff would be different.

There is also a list of the features added to 3.4 posted on the forums.

I was simply trying to save you work, mos of the changes incorporated to allow encrypted passwords and fix some security loop holes mean you will have to upgrade or stick with 3.3, the changes are to fundamental to try and fit into your existing code, beleive me, I have seen it.

Go to Top of Page
Page: of 6 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.22 seconds. Powered By: Snitz Forums 2000 Version 3.4.07