Ae pessoal o sistema de BBCODE completo como eu queria parecido ao desse fórum.
Só não tem QUOTE e CODE o resto está perfeito.
Ele consiste em 4 funções para o seu funcionamento e os mesmos devem seguir essa ordem.
Só peço que mantenha os direitos autorais de cada um.
trata_url.asp OBS: Aqui vc deve alterar o caminho das imagens dos smiles
<!--
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++ SISTEMA DE BBCODE EM ASP ++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sistema de BBCODE em ASP desenvolvido pela comunidade do fórum WMONLINE
Dúvidas, elogios, bugs, sugestões ou idéias basta acessar http://forum.wmonline.com.br
##########################################################################################
Por favor mantenha os créditos abaixo:
##########################################################################################
<%Rafael%>, lazerediversao, Info_Tec e [webmaster]®
##########################################################################################
-->
<%
Function BB(Conteudo)
conteudo = replace(conteudo, "[B]", "<b>")
conteudo = replace(conteudo, "[b]", "<b>")
conteudo = replace(conteudo, "[/B]", "</b>")
conteudo = replace(conteudo, "[/b]", "<b>")
conteudo = replace(conteudo, "[I]", "<i>")
conteudo = replace(conteudo, "[i]", "<i>")
conteudo = replace(conteudo, "[/I]", "</i>")
conteudo = replace(conteudo, "[/i]", "<i>")
conteudo = replace(conteudo, "[U]", "<u>")
conteudo = replace(conteudo, "[u]", "<u>")
conteudo = replace(conteudo, "[/U]", "</u>")
conteudo = replace(conteudo, "[/u]", "<u>")
conteudo = replace(conteudo, "[font=", "[FONT=")
conteudo = replace(conteudo, "[FONT=Arial]", "<font face='Arial'>")
conteudo = replace(conteudo, "[FONT=Times]", "<font face='Times'>")
conteudo = replace(conteudo, "[FONT=Courier]", "<font face='Courier'>")
conteudo = replace(conteudo, "[FONT=Impact]", "<font face='Impact'>")
conteudo = replace(conteudo, "[FONT=Geneva]", "<font face='Geneva'>")
conteudo = replace(conteudo, "[FONT=Optima]", "<font face='Optima'>")
conteudo = replace(conteudo, "[/FONT]", "</font>")
conteudo = replace(conteudo, "[/font]", "</font>")
conteudo = replace(conteudo, "[size=", "[SIZE=")
conteudo = replace(conteudo, "[SIZE=1]", "<font size='2'>")
conteudo = replace(conteudo, "[SIZE=2]", "<font size='3'>")
conteudo = replace(conteudo, "[SIZE=3]", "<font size='4'>")
conteudo = replace(conteudo, "[/SIZE]", "</font>")
conteudo = replace(conteudo, "[/font]", "</font>")
conteudo = replace(conteudo, "[color=", "[COLOR=")
conteudo = replace(conteudo, "[COLOR=blue]", "<font color='#0000FF'>")
conteudo = replace(conteudo, "[COLOR=red]", "<font color='#FF0000'>")
conteudo = replace(conteudo, "[COLOR=purple]", "<font color='#800080'>")
conteudo = replace(conteudo, "[COLOR=orange]", "<font color='#FFA500'>")
conteudo = replace(conteudo, "[COLOR=yellow]", "<font color='#FFFF00'>")
conteudo = replace(conteudo, "[COLOR=gray]", "<font color='#808080'>")
conteudo = replace(conteudo, "[COLOR=green]", "<font color='#008000'>")
conteudo = replace(conteudo, "[/COLOR]", "</font>")
conteudo = replace(conteudo, "[/color]", "</font>")
conteudo = replace(conteudo, "[IMG]", "<img src='")
conteudo = replace(conteudo, "[img]", "<img src='")
conteudo = replace(conteudo, "[/IMG]", "' border='0'>")
conteudo = replace(conteudo, "[/img]", "' border='0'>")
conteudo = replace(conteudo, ":huh:", "<img src='imagens/smile/huh.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":o", "<img src='imagens/smile/ohmy.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ";)", "<img src='imagens/smile/wink.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":P", "<img src='imagens/smile/tongue.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":D", "<img src='imagens/smile/biggrin.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":lol:", "<img src='imagens/smile/laugh.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, "B)", "<img src='imagens/smile/cool.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":rolleyes:", "<img src='imagens/smile/rolleyes.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":ROLLEYES:", "<img src='imagens/smile/rolleyes.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":emo:", "<img src='imagens/smile/dry.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":)", "<img src='imagens/smile/smile.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":angry:", "<img src='imagens/smile/mad.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":(", "<img src='imagens/smile/sad.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":unsure:", "<img src='imagens/smile/unsure.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":wacko:", "<img src='imagens/smile/wacko.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":blink:", "<img src='imagens/smile/blink.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, ":ph34r:", "<img src='imagens/smile/ph34r.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, "(n)", "<img src='imagens/smile/thumbs_down.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, "(y)", "<img src='imagens/smile/thumbs_up.gif' border='0' width='20' height='20'>")
conteudo = replace(conteudo, "[LIST]", "<ul>")
conteudo = replace(conteudo, "[list]", "<ul>")
conteudo = replace(conteudo, "[/LIST]", "</ul>")
conteudo = replace(conteudo, "[/list]", "</ul>")
conteudo = replace(conteudo, "[*]", "<li>")
conteudo = replace(conteudo, "[/*]", "</li>")
conteudo = replace(conteudo,chr(13),"<br>")
conteudo = Replace(conteudo,"[url=","[URL=")
conteudo = Replace(conteudo,"[/url]","[/URL]")
'Response.Write(Conteudo) & "<br><br>"
If InStr(1,conteudo,"[URL=") > 0 AND InStr(1,conteudo,"[/URL]") > 0 Then
Do While InStr(1,conteudo,"[URL=") > 0 OR InStr(1,conteudo,"[/URL]") > 0
tempInicio_URL = InStr(1,conteudo,"[URL=")
tempFim_URL = InStr(1,conteudo,"[/URL]")+6
' Verificando se existe endereço para linkar
If Not tempFim_URL - InStr(1,conteudo,"]",1) > 1 Then
Exit Do
End If
' Verificando se existe Apelido para o link
If tempFim_URL < tempInicio_URL Then
Exit Do
End If
Num_Caracteres = tempFim_URL - tempInicio_URL
Var_URL = Mid(conteudo, tempInicio_URL, Num_Caracteres)
Inicio_URL = InStr(1,Var_URL,"[URL=")
Fim_URL = InStr(1,Var_URL,"[/URL]") + 6
FechaColchete = InStr(Inicio_URL+5,Var_URL,"]")'posicao do colchete
'PegaColchete = Mid(Var_URL,FechaColchete,1)'pega o [
Endereco_URL = Mid(conteudo,Inicio_URL+5,FechaColchete-6)
'aqui faço o tratamento http:// com uma função que eu fiz (tá no include)
Endereco_URL_Tratado = TrataHttp(Endereco_URL)
Apelido_URL = Mid(Var_URL,FechaColchete+1,Fim_URL-6)
Var_URL_Original = Replace(Var_URL,Endereco_URL, Endereco_URL_Tratado)
'PegaColchete = Mid(Var_URL,FechaColchete,1)
'TransEmMaior = Replace(PegaColchete,"]",">")
If InStr(1,Var_URL,"http://") >= 6 Then
Var_URL = Replace(Var_URL,"[URL=", "<a href=""")
Else
Var_URL = Replace(Var_URL,"[URL=", "<a href=""http://")
End If
Var_URL = Replace(Var_URL,"[/URL]", "</a>")
'Var_URL = Replace(Var_URL, FechaColchete, ">")
Var_URL = Replace(Var_URL,"]", """ target=""_blank"">",1,1,0)
conteudo = Replace(conteudo, Var_URL_Original, Var_URL)
Loop
End IF
BB = Conteudo
End Function
%>
trata_mail.asp
<%
Function BB2(Conteudo)
conteudo = Replace(conteudo,"[email=","[EMAIL=")
conteudo = Replace(conteudo,"[/email]","[/EMAIL]")
'Response.Write(Conteudo) & "<br><br>"
If InStr(1,conteudo,"[EMAIL=") > 0 AND InStr(1,conteudo,"[/EMAIL]") > 0 Then
Do While InStr(1,conteudo,"[EMAIL=") > 0 OR InStr(1,conteudo,"[/EMAIL]") > 0
tempInicio_URL = InStr(1,conteudo,"[EMAIL=")
tempFim_URL = InStr(1,conteudo,"[/EMAIL]")+8
' Verificando se existe endereço para linkar
If Not tempFim_URL - InStr(1,conteudo,"]",1) > 1 Then
Exit Do
End If
' Verificando se existe Apelido para o link
If tempFim_URL < tempInicio_URL Then
Exit Do
End If
Num_Caracteres = tempFim_URL - tempInicio_URL
Var_URL = Mid(conteudo, tempInicio_URL, Num_Caracteres)
Inicio_URL = InStr(1,Var_URL,"[EMAIL=")
Fim_URL = InStr(1,Var_URL,"[/EMAIL]") + 8
FechaColchete = InStr(Inicio_URL+5,Var_URL,"]")'posicao do colchete
'PegaColchete = Mid(Var_URL,FechaColchete,1)'pega o [
Endereco_URL = Mid(conteudo,Inicio_URL+5,FechaColchete-6)
'aqui faço o tratamento mailto: com uma função que eu fiz (tá no include)
Endereco_URL_Tratado = Tratamail(Endereco_URL)
Apelido_URL = Mid(Var_URL,FechaColchete+1,Fim_URL-6)
Var_URL_Original = Replace(Var_URL,Endereco_URL, Endereco_URL_Tratado)
'PegaColchete = Mid(Var_URL,FechaColchete,1)
'TransEmMaior = Replace(PegaColchete,"]",">")
If InStr(1,Var_URL,"mailto:") >= 6 Then
Var_URL = Replace(Var_URL,"[EMAIL=", "<a href=""")
Else
Var_URL = Replace(Var_URL,"[EMAIL=", "<a href=""mailto:")
End If
Var_URL = Replace(Var_URL,"[/EMAIL]", "</a>")
'Var_URL = Replace(Var_URL, FechaColchete, ">")
Var_URL = Replace(Var_URL,"]", """ target=""_blank"">",1,1,0)
conteudo = Replace(conteudo, Var_URL_Original, Var_URL)
Loop
End IF
BB2 = Conteudo
End Function
%>
trata_http.asp
<%
Function TrataHttp(strURL)
If strURL <> "" Then
If Not InStr(1,strURL,"http://") > 0 Or Left(LCase(strURL), 7) <> "http://" Then
strURL = "http://" & strURL
'Else
'nada
End If
Else
strURL = ""
End If
TrataHttp = strURL
End Function
%>
trata_mailto.asp
[CODE]<%
Function Tratamail(strURL)
If strURL <> "" Then
If Not InStr(1,strURL,"mailto:") > 0 Or Left(LCase(strURL), 7) <> "mailto:" Then
strURL = "mailto:" & strURL
'Else
'nada
End If
Else
strURL = ""
End If
Tratamail = strURL
End Function
%>
Por fim na sua página onde vc quer que apareça o BBCODE vc deve inserir o seguinte.
<!--#include file="trata_url.asp"-->
<!--#include file="trata_mail.asp"-->
<!--#include file="trata_http.asp"-->
<!--#include file="trata_mailto.asp"-->
<%
'Seu código vem aqui
conteudo = seus_dados("seus_dados")
conteudo = Server.HTMLEncode(conteudo)
conteudo = BB(conteudo)
conteudo = BB2(conteudo)
%>
Depois é só vc inserir <%=conteudo%> em qualquer parte do seu site abaixo do código.
Bem é só isso por enquanto, espero que gostem.
Qualquer dúvida critica ou sugestões é só postar pessoal.
Sem mais agradeço a todos pela atenção dispençada.
Edição feita por: lazerediversao, 03/06/2005, 23:20.