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/O Code)
 Admin and Moderator text in topics
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Jorrit787
Average Member

Netherlands
681 Posts

Posted - 13 December 2004 :  04:16:27  Show Profile  Visit Jorrit787's Homepage  Send Jorrit787 an AOL message  Send Jorrit787 a Yahoo! Message
Not entirely sure if this belongs here, but if not then you can move it

I would like to know if it is possible to create tags, for example [hidden] and [/hidden], that work like this:

Normal users can't use the feature, but when admins or moderators use it, the text in-between the tags will only appear to admins and moderators I think it would be useful for admins and mods to leave little notes to each other to explain why they edit a specific post etc. that display directly under the post.

eXtremeGossip

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 13 December 2004 :  04:51:17  Show Profile  Visit MarcelG's Homepage
You could do it with the ExtraTags function in inc_func_common.asp, I guess.
if mlev > 2 then
'process the [hidden][/hidden] tags
else
'replace everything inbetween the [hidden][/hidden] tags and the tags themselves by something like this : 
'<b>Hidden for normal users</b>
end if
Something like that.
However, I have no clue on how to do the second one...

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 13 December 2004 04:52:38
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 13 December 2004 :  10:36:20  Show Profile  Visit dayve's Homepage
I have a function I could probably create for you but the syntax would look like this:

[hidden=This guy does not know what he's talking about, what should we do with him?]

Thanks to -gary and his approach with regular expressions, it would be pretty easy.

Go to Top of Page

Jorrit787
Average Member

Netherlands
681 Posts

Posted - 13 December 2004 :  11:39:47  Show Profile  Visit Jorrit787's Homepage  Send Jorrit787 an AOL message  Send Jorrit787 a Yahoo! Message
That sounds great

eXtremeGossip
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 13 December 2004 :  15:09:11  Show Profile  Visit MarcelG's Homepage
Dayve, you reckon it cannot be done (easily) with the [hidden]Hide this text[/hidden] method ?

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

-gary
Development Team Member

406 Posts

Posted - 13 December 2004 :  17:41:33  Show Profile
A RegEx is really the way to go here. This will give you one shotgun delete of everything between and including the tags. The pure VB way would require a bit more code and multiple passes for each iteration.

RegEx

<%
txt = HideText(txt)

function HideText(txt)
	Set xml = Server.CreateObject("Microsoft.XMLHTTP")
	Set regEx = New RegExp
	regEx.Pattern = "\[hidden.*\/hidden\]"
	regEx.IgnoreCase = True
	regEx.Global = True
	Set Matches = regEx.Execute(txt)
	HideText = regEx.Replace(txt, "")
end function
%>

VBScript

<%
for each match in whatever
	txt = Replace(txt, "[hidden]" & TagData("hidden", txt) & "[/hidden]", "")
next

function TagData(strTag, strSource)
	lngStart = InStr( 1, LCase( strSource ), Chr(91) & LCase( strTag ) )
	If lngStart > 0 Then
		lngStart = InStr( lngStart, LCase( strSource ), Chr(93) ) + 1
		lngStop = InStr( lngStart, LCase( strSource ), Chr(91) & Chr(47) & LCase( strTag ) & Chr(93) )
		If lngStart > 0 And lngStop > lngStart Then
			strData = Trim( Mid( strSource, lngStart, lngStop - lngStart ) )
		end if
	End If
	TagData = strData
end function
%>

KawiForums.com



Edited by - -gary on 13 December 2004 17:45:07
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 13 December 2004 :  20:13:16  Show Profile  Visit dayve's Homepage
LOL, there ya go... -gary has really opened my eyes to a lot of possibilities using regex lately.

Go to Top of Page

Jorrit787
Average Member

Netherlands
681 Posts

Posted - 14 December 2004 :  11:52:25  Show Profile  Visit Jorrit787's Homepage  Send Jorrit787 an AOL message  Send Jorrit787 a Yahoo! Message
To what file should I add this text? And should I use the RegEx or VBScript version?

This will allow moderators and admins to use the [hidden] [/hidden] tags to add text to posts that only they can see, right?

eXtremeGossip
Go to Top of Page

-gary
Development Team Member

406 Posts

Posted - 14 December 2004 :  13:00:59  Show Profile
It would go somewhere in the inc_func_common.asp file, but I'll let someone else do the implementation if they want since I don't have the time to dig into it right now.

Wether to use VB or RegEx is up to you. Some servers don't have the correct, or any, RegEx engine installed and some people just prefer doing it the VBScript way since you don't have to create an objects to use it. RegEx will be faster, though I wouldn't think by much in this case, but it is a cleaner solution.

KawiForums.com


Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 16 December 2004 :  01:18:55  Show Profile  Visit dayve's Homepage
I don't think the line of code in red is needed...

<%
txt = HideText(txt)

function HideText(txt)
	Set xml = Server.CreateObject("Microsoft.XMLHTTP")
	Set regEx = New RegExp
	regEx.Pattern = "\[hidden.*\/hidden\]"
	regEx.IgnoreCase = True
	regEx.Global = True
	Set Matches = regEx.Execute(txt)
	HideText = regEx.Replace(txt, "")
end function
%>


this will also only replace one instance of the tag...

David [hidden]Jason[/hidden] Michael [hidden]Harris[/hidden] Ferrick

would show...

David Ferrick

However, I got the method I initially recommended to work using the [hidden=some text] syntax


Function HideText(fString)
 Dim objRegExpr, Matches
  Set objRegExpr = New regexp
   objRegExpr.Pattern = "\[hidden=.*?\]"
   objRegExpr.Global = True
   objRegExpr.IgnoreCase = True
   Set Matches = objRegExpr.Execute(fString)   
    for each match in Matches
	 fString = Replace(fString, Match.Value, "")
    next
   Set Matches = Nothing
  Set objRegExpr = Nothing
 HideText = fString
End Function




Edited by - dayve on 16 December 2004 01:47:06
Go to Top of Page

-gary
Development Team Member

406 Posts

Posted - 16 December 2004 :  11:06:56  Show Profile
quote:
Originally posted by dayve

I don't think the line of code in red is needed...



You're right, that was a cut and paste from an existing function I had and forgot to take it out.

quote:

this will also only replace one instance of the tag...

David [hidden]Jason[/hidden] Michael [hidden]Harris[/hidden] Ferrick

would show...

David Ferrick



Change it to non-greedy by using this instead. "\[hidden.*?\/hidden\]"

KawiForums.com


Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 16 December 2004 :  12:33:34  Show Profile  Visit dayve's Homepage
PERFECT!

<%
function HideText(txt)
	Set regEx = New RegExp
	regEx.Pattern =  "\[hidden.*?\/hidden\]"
	regEx.IgnoreCase = True
	regEx.Global = True
	Set Matches = regEx.Execute(txt)
	HideText = regEx.Replace(txt, "")
end function

Response.Write HideText("David [hidden]Jason[/hidden] Michael [hidden]Harris[/hidden] Ferrick")
%>

gives me David Michael Ferrick

Go to Top of Page

Jorrit787
Average Member

Netherlands
681 Posts

Posted - 16 December 2004 :  16:55:38  Show Profile  Visit Jorrit787's Homepage  Send Jorrit787 an AOL message  Send Jorrit787 a Yahoo! Message
Do I have to add the Response.Write Hidetext line to inc_func_common as well?

eXtremeGossip
Go to Top of Page
  Previous Topic Topic Next Topic  
 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.28 seconds. Powered By: Snitz Forums 2000 Version 3.4.07