📄 func-htmlcode.asp
字号:
<%
'Converts html code back into html code for viewing by the user.
function htmlcode(content_in)
content = content_in
if content <> "" then
content = revert_smilies(content)
content = revert_quote(content)
content = revert_img(content)
content = revert_url(content)
content = revert_format(content)
content = replace(content, "<BR>", vbcrlf)
end if
htmlcode = content
end function
function revert_format(content_in)
'Convert all html formating into bbCode
content = content_in
content = replace(content, "<b>", "[B]")
content = replace(content, "</b>", "[/B]")
content = replace(content, "<i>", "[I]")
content = replace(content, "</i>", "[/I]")
content = replace(content, "<u>", "[U]")
content = replace(content, "</u>", "[/U]")
content = replace(content, "<s>", "[S]")
content = replace(content, "</s>", "[/S]")
content = replace(content, "<UL>", "[LIST]")
content = replace(content, "</UL>", "[/LIST]")
content = replace(content, "<OL>", "[LIST=1]")
content = replace(content, "</OL>", "[/LIST=1]")
content = replace(content, "<OL TYPE=A>", "[LIST=A]")
content = replace(content, "</OL TYPE=A>", "[/LIST=A]")
content = replace(content, "<li>", "[*]")
content = replace(content, "<table bgcolor=black><tr><td bgcolor=black><font size=1 color=white>Spoiler: (highlight to view)</font></td></tr><tr><td><font size=2 color=black>", "[SPOILER]")
content = replace(content, "</font></td></tr></table>", "[/SPOILER]")
content = replace(content, "<font size=""1"">", "[SIZE=1]")
content = replace(content, "<font size=""2"">", "[SIZE=2]")
content = replace(content, "<font size=""3"">", "[SIZE=3]")
content = replace(content, "<font size=""4"">", "[SIZE=4]")
content = replace(content, "<font size=""5"">", "[SIZE=5]")
content = replace(content, "<font size=""6"">", "[SIZE=6]")
content = replace(content, "</font s>", "[/SIZE]")
content = replace(content, "<font color=""black"">", "[COLOR=BLACK]")
content = replace(content, "<font color=""white"">", "[COLOR=WHITE]")
content = replace(content, "<font color=""blue"">", "[COLOR=BLUE]")
content = replace(content, "<font color=""red"">", "[COLOR=RED]")
content = replace(content, "<font color=""green"">", "[COLOR=GREEN]")
content = replace(content, "<font color=""yellow"">", "[COLOR=YELLOW]")
content = replace(content, "<font color=""orange"">", "[COLOR=ORANGE]")
content = replace(content, "<font color=""brown"">", "[COLOR=BROWN]")
content = replace(content, "<font color=""magenta"">", "[COLOR=MAGENTA]")
content = replace(content, "<font color=""cyan"">", "[COLOR=CYAN]")
content = replace(content, "</font c>", "[/COLOR]")
revert_format = content
end function
function revert_url(content_in)
'Replace all hyperlinks with their equivalent bbCode
content = content_in
do while instr(1, content, "<a href=""", 1) > 0 and InStr(1, content, """ target=""_blank"">", 1) > 0
'Locate the complete hyperlink
open_tag = instr(1, content, "<a href=""", 1)
close_tag = instr(open_tag, content, "</a>", 1) + 4
original_url = trim(mid(content, open_tag, (close_tag - open_tag)))
'Isolate the URL and the link
original_url = trim(mid(content, open_tag, (close_tag - open_tag)))
new_url = original_url
new_url = replace(new_url, "<a href=""", "", 1, -1, 1)
new_url = replace(new_url, "</a>", "", 1, -1, 1)
url = left(new_url, instr(1, new_url, """ target=""_blank"">") -1)
link = new_url
link = replace(link, url, "")
link = replace(link, """ target=""_blank"">", "")
'Build BBcode with filtered URL depending on whether the url and link match
if len(link) > 0 then
new_url = "[URL=" & url & "]" & link & "[/URL]"
else
new_url = "[URL]" & url & "[/URL]"
end if
'Insert BBCode into text
content = replace(content, original_url, new_url, 1, -1, 1)
loop
'Output altered text
revert_url = content
end function
function revert_img(content_in)
'Replace all image links within the specified text
content = content_in
do while instr(1, content, "<img src=", 1) > 0 and InStr(1, content, """ border=""0"">", 1) > 0
'Locate complete <img> code
open_tag = instr(1, content, "<img src=", 1)
close_tag = instr(open_tag, content, """ border=""0"">", 1) + 13
original_image = trim(mid(content, open_tag, (close_tag - open_tag)))
'Isolate the image location
new_image = original_image
new_image = replace(new_image, "<img src=""", "", 1, -1, 1)
new_image = replace(new_image, """ border=""0"">", "", 1, -1, 1)
'Replace <img> code with BB tags
new_image = "[IMG]" & new_image & "[/IMG]"
'Insert BBCode into text
content = replace(content, original_image, new_image, 1, -1, 1)
loop
'Output the final altered text
revert_img = content
end function
function revert_quote(content_in)
'Replace all <blockuote> tags in the specified text
content = content_in
'If the quoted text contains any quotes locate the complete <blockquote> code and remove it
do while instr(1, content, "<blockquote>", 1) > 0 and InStr(1, content, "</blockquote>", 1) > 0
open_tag = instr(1, content, "<blockquote>", 1)
close_tag = instr(open_tag, content, "</blockquote>", 1) + 13
original_quote = trim(mid(content, open_tag, (close_tag - open_tag)))
new_quote = original_quote
new_quote = replace(new_quote, "<blockquote><hr>", "[QUOTE]", 1, -1, 1)
new_quote = replace(new_quote, "<hr></blockquote>", "[/QUOTE]", 1, -1, 1)
'Insert HTML into text
content = replace(content, original_quote, new_quote, 1, -1, 1)
loop
revert_quote = content
end function
function revert_smilies(content_in)
'Replace all smilies in the specified text
content = content_in
set rsSmilies = server.createobject("adodb.recordset")
sqlSmilies = "SELECT Smiley_Code, Smiley_Image FROM Forum_Smilies;"
rsSmilies.open sqlSmilies, adoConn, CMDText
if rsSmilies.eof or rsSmilies.bof then
rsSmilies.close
set rsSmilies = nothing
else
SmileyCnt = rsSmilies.recordcount
SmileyData = rsSmilies.getrows()
rsSmilies.close
set rsSmilies = nothing
end if
for pos = 0 to SmileyCnt-1
smiley = "<img src='Images/Smilies/" & SmileyData(1, pos) & "' border='0'>"
content = replace(content, smiley, SmileyData(0, pos))
next
revert_smilies = content
end function
function remove_quote(content_in)
'Remove all <blockuote> tags where applicable
content = content_in
'If the quoted text contains any quotes locate the complete <blockquote> code and remove it
do while instr(1, content, "<blockquote>", 1) > 0 and InStr(1, content, "</blockquote>", 1) > 0
open_tag = instr(1, content, "<blockquote>", 1)
close_tag = instr(open_tag, content, "</blockquote>", 1) + 13
original_quote = trim(mid(content, open_tag, (close_tag - open_tag)))
'Insert HTML into text
content = replace(content, original_quote, "", 1, -1, 1)
loop
remove_quote = content
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -