T O P I C R E V I E W |
leatherlips |
Posted - 21 July 2009 : 14:01:34 Is there a general way to apply some code to a page that first requires a member to have a minimum number of posts before they can see it?
For example, say I have a page that I only want viewed if you made a minimum of 10 posts. If you had less than 10 you would see something like:
"You must have made at least 10 posts to see this page."
If they had 10 or more posts they would instead see the pages normal contents.
If there is not a general "one size fits all" code for this to apply to a page then I'll re-ask the question here for the specific page I have in mind. |
14 L A T E S T R E P L I E S (Newest First) |
Carefree |
Posted - 04 April 2014 : 02:24:22 I completely redid this package for the modular Snitz that I'm working on. Instead of having to include the file on each page you want controlled, the included page is called from "inc_header" and "inc_header_short". You simply add/delete/edit the page names to be controlled from an admin console page. You can also change the minimum number of posts there.
The include page also has an override function for the forum admininistrator/administrators/moderators, depending on the option chosen from the admin console. Just need to fix the onclick function for the radio buttons, it's being a mite stubborn. That's resolved and it's up on SnitzBitz. |
Carefree |
Posted - 23 July 2009 : 03:12:22 The section in red is required to handle those people who aren't logged in. If someone isn't logged in, then the check for their account (where M.MEMBER_ID = " & MemberID) will hit an end-of-file and they'll get the same message.
Thus, no change should be required. However, make sure those "end if" commands are not on the same lines as the "Response.End" commands. |
leatherlips |
Posted - 22 July 2009 : 18:50:27 It is starting to work great now! You're awesome!
I have a couple more questions.
Just for my information, because I don't completly understand your code. But what is the section in red for? It seems to copy the section in green.
Also, before adding your code, the page also checked to be sure you were logged in before you could see it. Now it does not check for that. Can it still be tweaked to do that? Line 140 of your revised pop_upload_new.asp page is where part of the section is.
So to sum up, for this page I want it to:
1. Check if they are logged in, if not, they can't see the page. 2. If they are logged in, check to see if they have the minimum number of posts, if not, they can't see the page. 3. If they are logged in and have the required number of minimum posts, then they can see the page.
So far numbers 2 and 3 work. Now for number 1. |
Carefree |
Posted - 22 July 2009 : 16:53:14 OK. Here you go.
Now, here's your code fixed to not display the page.
|
leatherlips |
Posted - 22 July 2009 : 15:29:07 Carefree,
Now it is displaying the message but it still also shows the real page.
Maybe this will help.
Here is the page I am trying to get this to work on...
|
Carefree |
Posted - 22 July 2009 : 13:36:25 quote: Originally posted by leatherlips
Carefree,
Now I am getting this text on top of the page I have added it to:
Insufficient posts to view this page. META HTTP-EQUIV="refresh" CONTENT="7; url="javascript:history.back()">Return to previous page.
It also has all of the normal content of the page displaying.
Shaggy,
I do not know how to do what you are asking. However, the page I am trying Carefree's code on does not have inc_header.asp in it. It instead has inc_header_short.asp. Perhaps that is why I am having a problem?
Or simply add an opening bracket ( < ) before the two META HTTP bits. |
Shaggy |
Posted - 22 July 2009 : 10:25:37 Find the following on line 127 of config.asp and add the code in green:Dim mLev, strLoginStatus, MemberID, strArchiveTablePrefix, intMemberPosts Find the chkUser function on line 893 of inc_func_common.asp and add the code in green:function chkUser(fName, fPassword, fAuthor)
dim rsCheck
dim strSql
'## Forum_SQL
strSql = "SELECT MEMBER_ID, M_LEVEL, M_NAME, M_PASSWORD, M_POSTS "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(fName, "SQLString") & "' "
if strAuthType="db" then
strSql = strSql & " AND M_PASSWORD = '" & ChkString(fPassword, "SQLString") &"'"
End If
strSql = strSql & " AND M_STATUS = " & 1
Set rsCheck = my_Conn.Execute(strSql)
if rsCheck.BOF or rsCheck.EOF or not(ChkQuoteOk(fName)) or not(ChkQuoteOk(fPassword)) then
MemberID = -1
intMemberPosts=0
chkUser = 0 '## Invalid Password
if strDBNTUserName <> "" and chkCookie = 1 then
Call ClearCookies()
strDBNTUserName = ""
end if
else
MemberID = rsCheck("MEMBER_ID")
intMemberPosts=clng(rsCheck("M_POSTS"))
strDBNTUserName = rsCheck("M_NAME")
if (rsCheck("MEMBER_ID") & "" = fAuthor & "") and (cLng(rsCheck("M_LEVEL")) <> 3) then
chkUser = 1 '## Author
else
select case cLng(rsCheck("M_LEVEL"))
case 1
chkUser = 2 '## Normal User
case 2
chkUser = 3 '## Moderator
case 3
chkUser = 4 '## Admin
case else
chkUser = cLng(rsCheck("M_LEVEL"))
end select
end if
end if
rsCheck.close
set rsCheck = nothing
end function The intMemberPosts variable will now be available to use on any page that includes config.asp and inc_header(_short).asp. If you're not including config.asp then be sure to dim intMemberPosts elsewhere in your script. If you're not including one of the inc_header.asp, you can still assign a value to the variable with a call to the chkUser function, assuming you are including inc_func_common.asp.
|
leatherlips |
Posted - 22 July 2009 : 09:53:24 Carefree,
Now I am getting this text on top of the page I have added it to:
Insufficient posts to view this page. META HTTP-EQUIV="refresh" CONTENT="7; url="javascript:history.back()">Return to previous page.
It also has all of the normal content of the page displaying.
Shaggy,
I do not know how to do what you are asking. However, the page I am trying Carefree's code on does not have inc_header.asp in it. It instead has inc_header_short.asp. Perhaps that is why I am having a problem? |
Shaggy |
Posted - 22 July 2009 : 05:11:50 Rather than hitting the database again, you could use the chkUser function to pull the value of M_POSTS and assign it to a a variable which would be available in any page that includes inc_header.asp. Don't forget to dim your new variable outside of the function, as we do with MemberID in config.asp.
|
Carefree |
Posted - 22 July 2009 : 00:13:51 OK - I found the error and fixed it. Should be good to go. |
leatherlips |
Posted - 21 July 2009 : 19:31:37 No more error. But the page can still be seen. I am testing it on a demo account with 8 posts. Is there something else I need to have on the page? |
Carefree |
Posted - 21 July 2009 : 19:10:01 Whoops, sorry. Typo deleted part of a line.
Fixed above. |
leatherlips |
Posted - 21 July 2009 : 18:07:11 Thanks. I like the include idea.
I am currently getting this error:
Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/forumtest/inc_minposts.asp, line 3
strSql = strSql & " set rs = my_Conn.Execute (strSql)
-----------------------------------------------------^
The page I put this on is a pop up page. Does your code require another include of another fourm page? |
Carefree |
Posted - 21 July 2009 : 16:38:33 This should do it. Post value will be in "intMPosts" when executed.
To avoid adding all the lines to each page, you can turn this into an include by modifying it as follows and saving it as "inc_minposts.asp". Then to use it, you'd simply have to add an include statement where you want it checked.
Include statement:
%>
<!--#INCLUDE file="inc_minposts.asp" -->
<%
|
|
|