Author |
Topic  |
aspwiz
Junior Member
 
250 Posts |
Posted - 25 November 2004 : 14:00:19
|
Have you ever put stuff in code boxes, only to have forum code applied to the contents of the code box? when pasting code into the boxes, often they may have url's or other things that would be acted upon by forum code.
This mod basically makes sure everything in [.code] [/.code] boxes remains exactly intact... forum code will not be parsed inside the tags.
BEGIN MOD [UPDATED FOR BASE CODE INSTALL]
Firstly, add the following variable declaration to config.asp:-
Dim CloakString open inc_func_common.asp and add these two functions (They can go pretty much anywhere.... I put mine at the end of the file):-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 Still inside inc_func_common.asp, find the function called formatstr and then, find this line within it:-fString = ReplaceURLs(fString) insert this directly BEFORE that line fstring = Cloak(fstring) 'Remove code tag content to prevent forum code formatting next, find this line a few lines down:-fString = ReplaceCodeTags(fString) and REMOVE IT. Lastly, find this line at the end of the the function:-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 27 November 2004 07:12:11 |
|
Da_Stimulator
DEV Team Forum Moderator
    
USA
3373 Posts |
Posted - 25 November 2004 : 14:19:39
|
Sweet I've been meaning to do something like this...
Nice  |
-Stim |
 |
|
dayve
Forum Moderator
    
USA
5820 Posts |
Posted - 25 November 2004 : 16:50:55
|
quote: Originally posted by Da_Stimulator
Sweet I've been meaning to do something like this...
Nice 
you and me both... I'm glad someone has finally decided to get this done. I'm going to test it right now. |
|
 |
|
dayve
Forum Moderator
    
USA
5820 Posts |
Posted - 25 November 2004 : 16:56:13
|
fString = ChkAHREFs(fString) does not exist... or I am very tired today and I am missing it. |
|
 |
|
Da_Stimulator
DEV Team Forum Moderator
    
USA
3373 Posts |
Posted - 25 November 2004 : 17:24:20
|
perhaps in base code it'd be edit_hrefs or ChkURLs.... |
-Stim |
Edited by - Da_Stimulator on 25 November 2004 17:24:38 |
 |
|
aspwiz
Junior Member
 
250 Posts |
Posted - 26 November 2004 : 05:22:24
|
basically enter that line before any forum code parsing....
I know my forum has changed a hell of a lot from the base code.
Let me know if you get it going on base code, and what amendments i should make to the instructions above. |
 |
|
dayve
Forum Moderator
    
USA
5820 Posts |
Posted - 26 November 2004 : 11:32:51
|
I may have done something wrong (as mine is also heavily modified), but my code box now produces this text:
xxxCODEBOXxxx
I think I am going to actually spend time examining what it is your code does before I apply it again. |
|
Edited by - dayve on 26 November 2004 11:33:21 |
 |
|
aspwiz
Junior Member
 
250 Posts |
Posted - 26 November 2004 : 11:34:26
|
dayve, I think you may have forgot to add the decloak function call just before the formatstr function ends. |
 |
|
MarcelG
Retired Support Moderator
    
Netherlands
2625 Posts |
Posted - 26 November 2004 : 14:45:44
|
whooohooo!!! working as a charm! To get it into the basecode you need to change the step concerning the chkAHREFs(fString) and use line of
if strAllowForumCode = "1" then Afaik that's in the basecode, just before
fString = ReplaceURLs(fString)
However, it does change the [b][/b] tags into <b></b> ...  I also had to move the Dim Cloakstring line to config.asp, instead of inc_func_common.asp to get it working for more than 1 minute... After some time it gave me the error 'Name redefined'....
Demo: http://www.oxle.nl/topic.asp?TOPIC_ID=1767 |
portfolio - linkshrinker - oxle - twitter |
Edited by - MarcelG on 26 November 2004 15:03:34 |
 |
|
Davio
Development Team Member
    
Jamaica
12217 Posts |
Posted - 26 November 2004 : 15:19:23
|
Definetly a good mod. Will install it when you all work out the little bugs.  |
Support Snitz Forums
|
 |
|
Gargoyle
Junior Member
 
USA
280 Posts |
|
aspwiz
Junior Member
 
250 Posts |
Posted - 27 November 2004 : 07:13:51
|
Ok.... I updated the instructions above, and everything will go fine now I hope.
Let me have any feedback.
Rob |
 |
|
Neilr
Junior Member
 
Australia
107 Posts |
Posted - 01 December 2004 : 07:09:15
|
Hi,
This is a great tool as we run comps where the member needs to include a standard image. This way we can give them the code to insert.
I can follow most of it except where to put this bit of code:
Dim CloakString
I know it says in the config.asp file but exactly where? All looks a dangerous for me to be fiddling about in that file. I am using 3.4.05
Tar
Neil. |
 |
|
MarcelG
Retired Support Moderator
    
Netherlands
2625 Posts |
|
Neilr
Junior Member
 
Australia
107 Posts |
Posted - 02 December 2004 : 00:27:39
|
quote: Originally posted by marcelgoertz
You can put it just after all the other lines saying DIM whatever
Sweet: that did it and it works a treat.. Thanks.
Neil |
 |
|
Neilr
Junior Member
 
Australia
107 Posts |
Posted - 02 December 2004 : 00:31:42
|
Oh forgot
How did you do the nice box thingie on your site? in the demo link I mean: I like that.
Neil |
 |
|
Topic  |
|