Copy Code code as follows:
'=====================================
' Convert content to prevent accidental
'=====================================
Function Content_encode (ByVal t0)
IF IsNull (t0) Or Len (t0) =0 Then
Content_encode= ""
Else
Content_encode=replace (t0, "<", "<")
Content_encode=replace (Content_encode, ">", ">")
End IF
End Function
'=====================================
' Reverse-transform content
'=====================================
Function Content_decode (ByVal t0)
IF IsNull (t0) Or Len (t0) =0 Then
Content_decode= ""
Else
Content_decode=replace (t0, "<", "<")
Content_decode=replace (Content_decode, ">", ">")
End IF
End Function
'=====================================
' Filter characters
'=====================================
Function FilterText (ByVal t0,byval t1)
IF Len (t0) =0 or IsNull (t0) or IsArray (t0) Then filtertext= "": Exit Function
T0=trim (t0)
Select Case T1
Case "1"
T0=replace (T0,CHR (32), "")
T0=replace (T0,CHR (13), "")
T0=replace (T0,CHR) &CHR (a), "<br>"
T0=replace (T0,CHR), "<br>"
Case "2"
T0=replace (T0,CHR (8), "") ' Back to Grid '
T0=replace (T0,CHR (9), "") ' tab (Horizontal tab)
T0=replace (T0,CHR (10), "") ' wrapping line
T0=replace (T0,CHR (one), "") ' tab (Vertical tab)
T0=replace (T0,CHR (12), "") ' Change page
T0=replace (T0,CHR (13), "") ' Carriage return Chr &CHR (10) Carriage return and line wrap combination
T0=replace (T0,CHR (22), "")
T0=replace (T0,CHR (32), "") ' Space spaces
T0=replace (T0,CHR (33), "") '!
T0=replace (T0,CHR (34), "") ' "
T0=replace (T0,CHR (35), "") '
T0=replace (T0,CHR (36), "") ' $
T0=replace (T0,CHR (37), "") '%
T0=replace (T0,CHR, "") &
T0=replace (T0,CHR (39), "") "
T0=replace (T0,CHR (40), "") ' (
T0=replace (T0,CHR (41), "")
T0=replace (T0,CHR (42), "") ' *
T0=replace (T0,CHR (43), "") ' +
T0=replace (T0,CHR (44), "") ',
T0=replace (T0,CHR (45), "") '-
T0=replace (T0,CHR (46), "").
T0=replace (T0,CHR (47), "") '/
T0=replace (T0,CHR (58), "") ':
T0=replace (T0,CHR (59), "") ';
T0=replace (T0,CHR), "" "<
T0=replace (T0,CHR (61), "") ' =
T0=replace (T0,CHR), "" ">
T0=replace (T0,CHR (63), "") '?
T0=replace (T0,CHR (64), "") ' @
T0=replace (T0,CHR (91), "") ' \
T0=replace (T0,CHR (92), "") ' \
T0=replace (T0,CHR (93), "")
T0=replace (T0,CHR (94), "") ' ^
T0=replace (T0,CHR (95), "") ' _
T0=replace (T0,CHR (96), "") "
T0=replace (T0,CHR (123), "") ' {
T0=replace (T0,CHR (124), "") ' |
T0=replace (T0,CHR (125), "") '}
T0=replace (T0,CHR (126), "") ' ~
Case Else
T0=replace (t0, "&", "&")
T0=replace (t0, "'", "" ")
T0=replace (t0, "" "", "" ")
T0=replace (t0, "<", "<")
T0=replace (t0, ">", ">")
End Select
IF Instr (Lcase (t0), "expression") >0 Then
T0=replace (t0, "expression", "expression", 1,-1, 0)
End If
Filtertext=t0
End Function
'=====================================
' Filter common characters and HTML
'=====================================
Function filterhtml (ByVal t0)
IF Len (t0) =0 or IsNull (t0) or IsArray (t0) Then filterhtml= "": Exit Function
IF Len (sdcms_badhtml) >0 Then t0=replacetext (t0, "< (\/|) ("&Sdcms_Badhtml&"), "<$1$2")
IF Len (sdcms_badevent) >0 Then t0=replacetext (t0, "<". [ ^>]*) ("&Sdcms_BadEvent&") "," <$1$2 ")
T0=filtertext (t0,0)
Filterhtml=t0
End Function
Function gottopic (ByVal t0,byval t1)
IF Len (t0) =0 Or IsNull (t0) Then
Gottopic= ""
Exit Function
End IF
Dim L,t,c, I
T0=replace (replace (replace (t0, "", ""), "", Chr ()), ">", ">"), "<", "<")
L=len (t0)
T=0
For I=1 to L
C=abs (ASC (t0,i,1))
IF c>255 Then t=t+2 Else t=t+1
IF t>=t1 Then
Gottopic=left (t0,i) & "..."
Exit for
Else
Gottopic=t0
End IF
Next
Gottopic=replace (replace (replace (Gottopic, "", ""), Chr (+), "" ")," > "," > ")," < "," < ")
End Function
Function UrlDecode (ByVal t0)
Dim T1,T2,T3,I,T4,T5,T6
T1= ""
T2=false
T3= ""
For I=1 to Len (t0)
T4=mid (t0,i,1)
IF t4= "+" Then
t1=t1& ""
ElseIF t4= "%" Then
T5=mid (t0,i+1,2)
T6=cint ("&h" & T5)
IF T2 Then
T2=false
T1=T1&CHR (Cint ("&h" &t3&t5))
Else
IF Abs (T6) <=127 Then
T1=T1&CHR (T6)
Else
T2=true
T3=t5
End IF
End IF
I=i+2
Else
T1=t1&t4
End IF
Next
Urldecode=t1
End Function
Function cutstr (byVal t0,byval t1)
Dim L,t,c,i
IF IsNull (t0) Then cutstr= "": Exit Function
L=len (t0)
T1=int (T1)
T=0
For I=1 to L
C=ASC (Mid (t0,i,1))
IF c<0 Or c>255 Then t=t+2 Else t=t+1
IF t>=t1 Then
Cutstr=left (t0,i) & "..."
Exit for
Else
Cutstr=t0
End IF
Next
End Function
Function closehtml (ByVal t0)
Dim T1,i,t2,t3,regs,matches,j,match
Set regs=new REGEXP
Regs.ignorecase=true
Regs.global=true
T1=array ("P", "div", "span", "table", "ul", "Font", "B", "U", "I", "H1", "H2", "H3", "H4", "H5", "H6")
For i=0 to UBound (T1)
T2=0
T3=0
Regs.pattern= "\<" &t1 (I) & "([^\<\>]+|) \> "
Set Matches=regs.execute (t0)
For the Match in matches
T2=t2+1
Next
Regs.pattern= "\</" &t1 (I) & "\>"
Set Matches=regs.execute (t0)
For the Match in matches
T3=t3+1
Next
For J=1 to T2-t3
t0=t0+ "</" &t1 (I) & ">"
Next
Next
Closehtml=t0
End Function