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

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: General / Classic ASP versions(v3.4.XX)
 unwanted url parsing in [code] boxes
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

aspwiz
Junior Member

250 Posts

Posted - 23 November 2004 :  04:37:45  Show Profile  Visit aspwiz's Homepage
Does anyone have an easy way to stop url's and other forum code being parsed within [.code] [/.code] boxes?

I thought that code boxes should PRESERVE everything.

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 23 November 2004 :  04:53:08  Show Profile  Visit HuwR's Homepage
No, it is only to preserve the layout
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 23 November 2004 :  07:23:56  Show Profile  Visit dayve's Homepage
I had an issue with this as well and created a hack that would prevent the parsing of url's and smilies once a [code] tag was use for the entire posting.


function FormatStr(fString)
	on Error resume next
	fString = Replace(fString, CHR(13), "")
	'fString = Replace(fString, CHR(10) & CHR(10), "<br /><br />")
	fString = Replace(fString, CHR(10), "<br />")
if InStr(fString, "<pre id=""code"">") = 0 then
	if strBadWordFilter = 1 or strBadWordFilter = "1" then
		fString = ChkBadWords(fString)
	end if

	if strAllowForumCode = "1" then
		fString = ReplaceURLs(fString)
		fString = ReplaceCodeTags(fString)
		if strIMGInPosts = "1" then
			fString = ReplaceImageTags(fString)
		end if
	end if

	fString = ChkURLs(fString, "http://", 1)
	fString = ChkURLs(fString, "https://", 2)
	fString = ChkURLs(fString, "www.", 3)
	fString = ChkMail(fString)
	fString = ChkURLs(fString, "ftp://", 5)
	fString = ChkURLs(fString, "file:///", 6)

	if strIcons = "1" then
		fString = smile(fString)
	end if
	if strAllowForumCode = "1" then
		fString = extratags(fString)
	end if
end if
	FormatStr = fString
	on Error goto 0
end function


Demo: http://www.burningsoulsforum.com/forum/topic.asp?TOPIC_ID=7658


Edited by - dayve on 23 November 2004 07:27:31
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 25 November 2004 :  03:01:43  Show Profile  Visit MarcelG's Homepage
Dayve, if I understand this correctly (and watch it in action on my own site) your hack removes the formatting for the entire post, once the [code] tag is used.

Isn't there a way to just not format the string that is within the [code][/code] tags ?
That would come in very handy!

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

aspwiz
Junior Member

250 Posts

Posted - 25 November 2004 :  04:09:08  Show Profile  Visit aspwiz's Homepage
What marcel said....

I'm gonna do this myself.

I'll just take all the content from all the code blocks, and chuck it in an array... I'll then replace the code blocks with placeholders, format the post, then add in the array contents in place of the placeholders!

Simple really.... yeah, right... lol
Go to Top of Page

aspwiz
Junior Member

250 Posts

Posted - 25 November 2004 :  06:19:53  Show Profile  Visit aspwiz's Homepage
ok... sorted this...

into inc_func_common, add these two functions:-
Function Cloak(fstring)
	set re = new RegExp
	re.pattern = "\[code\]([\s\S]+?)\[/code\]"
	re.ignorecase = true
	re.global = true
	set matches = re.execute(fstring) ' find matches
	if matches.count <> 0 then
		for each match in matches
			cloakstring = cloakstring & "!£$%^&*()_+" & match.value ' full match including tags
			fstring = replace(fstring,match.value,"xxxCODEBOXxxx",1,1)
		next
	end if
	Cloak = fstring
	set re = nothing
	set matches = nothing
end function

Function DeCloak(Fstring)
	cloakarray = split(cloakstring,"!£$%^&*()_+")
	for cntr = 1 to ubound(cloakarray)
		fstring = replace(fstring,"xxxCODEBOXxxx", cloakarray(cntr),1,1)
	next
	decloak = fstring
end function
At the very top of the file, just after the copyright comment block, we need to define a global variable..., so add this line:
Dim CloakString
find the function called formatstr and then, find this line:-
fString = ChkAHREFs(fString)
insert this directly before that line
fstring = Cloak(fstring) 'Remove code tag content to prevent forum code formatting
next, find this line:-
fString = ReplaceCodeTags(fString)
and REMOVE IT.
Lastly, find this line:-
FormatStr = fString
just BEFORE that line, add these two lines of code:
fstring = decloak(fstring) ' put back the code tags and content

	fString = ReplaceCodeTags(fString)
Voila!!!

Enjoy!

Edited by - aspwiz on 25 November 2004 06:24:28
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 25 November 2004 :  06:46:07  Show Profile  Visit MarcelG's Homepage
Mmm...sounds plausible! Gonna try it tonight! tnx

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

dayve
Forum Moderator

USA
5820 Posts

Posted - 25 November 2004 :  12:05:08  Show Profile  Visit dayve's Homepage
quote:
Originally posted by marcelgoertz

Dayve, if I understand this correctly (and watch it in action on my own site) your hack removes the formatting for the entire post, once the [code] tag is used.

Isn't there a way to just not format the string that is within the [code][/code] tags ?
That would come in very handy!


hence the reason it is a hack and not a mod. I was working on a way to do this..

http://forum.snitz.com/forum/topic.asp?TOPIC_ID=55531
http://forum.snitz.com/forum/topic.asp?TOPIC_ID=54891

however, I have redirected priorities on a new upload script for now.


Edited by - dayve on 25 November 2004 12:07:21
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.45 seconds. Powered By: Snitz Forums 2000 Version 3.4.07