webForumDet fria alternativet

HTML på trots server.htmlencode

2 svar · 164 visningar · startad av MoonCow

MoonCowMedlem sedan juni 2001225 inlägg
#1

Hej! Detta är inte bra... html går att använda trots att jag trodde jag "server.htmlencode"-at bort det..
min kod ser ut så här:

<%

textish = RecSet("mess")
   
'Text including codes to be converted
strText = textish

'HTMLencode to get rid of tags
strText = [b]Server.HTMLEncode(strText)[/b]
                   

strText = Replace(textish, ":)", "<img src='smiley.gif'>")
textish = Replace(textish, ":-)", "<img src='smiley.gif'>")
textish = Replace(textish, "=)", "<img src='smiley.gif'>")
textish = Replace(textish, ";)", "<img src='skamta.gif'>")
textish = Replace(textish, ";-)", "<img src='skamta.gif'>")
textish = Replace(textish, ":D", "<img src='stortsmajl.gif'>")
textish = Replace(textish, ":=D", "<img src='stortsmajl.gif'>")
textish = Replace(textish, ":-D", "<img src='stortsmajl.gif'>")
textish = Replace(textish, ":(", "<img src='sad.gif'>")
textish = Replace(textish, "=(", "<img src='sad.gif'>")
textish = Replace(textish, ":-(", "<img src='sad.gif'>")
textish = Replace(textish, ":p", "<img src='tongue.gif'>")
textish = Replace(textish, ":-p", "<img src='tongue.gif'>")
textish = Replace(textish, ":P", "<img src='tongue.gif'>")
textish = Replace(textish, "=P", "<img src='tongue.gif'>")

textish = Replace(textish, ":&#0124;", "<img src='duh.gif'>")
textish = Replace(textish, ":-&#0124;", "<img src='duh.gif'>")

textish = Replace(textish, ":O", "<img src='wow.gif'>")
textish = Replace(textish, ":-O", "<img src='wow.gif'>")

textish = Replace(textish, ">(", "<img src='hmm.gif'>")
textish = Replace(textish, ":???:", "<img src='ehh.gif'>")

textish = Replace(textish, ":rolleyes:", "<img src='rolleyes.gif'>")
textish = Replace(textish, ":julklapp:", "<img src='julklapp.gif'>")

textish = Replace(textish, vbcrlf, "<br>")

strText = textish

'Creates new regexp
Set objRegExp = New regexp

'Do more than once
objRegExp.Global = true

'Ignore whether upper or lowercase
objRegExp.IgnoreCase = true

'Replace colors

'Pattern to look for
objRegExp.Pattern = "\[(blue)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#003399"">")

'Pattern to look for
objRegExp.Pattern = "\[(red)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#CC0000"">")

'Pattern to look for
objRegExp.Pattern = "\<(b)\>"
'Execute the replacement
strText = objRegExp.Replace(strText,"<b>")

'Pattern to look for
objRegExp.Pattern = "\<(/b)\>"
'Execute the replacement
strText = objRegExp.Replace(strText,"</b>")

'Pattern to look for
objRegExp.Pattern = "\[(white)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#ffffff"">")

'Pattern to look for
objRegExp.Pattern = "\[(yellow)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#F8E187"">")

'Pattern to look for
objRegExp.Pattern = "\[(green)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#339933"">")

'Replace all ending tags with </font>
objRegExp.Pattern = "(\[\/blue\]&#0124;\[\/red\]&#0124;\[\/green\]&#0124;\[\/white\]&#0124;\[\/yellow\]&#0124;\[\/color\])"
strText = objRegExp.Replace(strText,"</font>")

response.write strText
%>

och trots detta (det felstilade) så fungerar html utmärkt och folk kan härja som dom vill :(.. Snälla hjälp mig!
mvh /Max

------------------
dom sa att en milion apor med skirvmaskiner skulle återskapa Shakespeares samlade verk om de bara fick tid... internet bevisade motsatsen

Erik JuhlinMedlem sedan maj 20007 625 inlägg
#2

Du använder ju inte strText sen utan går tillbaka till textish igen.

------------------
/Erik
www.juhlin.nu /sk8files/ /mp2d/

MoonCowMedlem sedan juni 2001225 inlägg
#3

hmm.. jag har sirrat mig blind på det men efter ha skippat dummheterna med att hoppa mellan textish och strText så fick jag det att funka.. tack...

mvh /Max

------------------
dom sa att en milion apor med skirvmaskiner skulle återskapa Shakespeares samlade verk om de bara fick tid... internet bevisade motsatsen

Genererad på 373 ms · cache AV · v20260730165559-full.f96bc7eb