Örnek verecek olursak


<%
Function LoseHTML(strHTML)
On Error Resume Next
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"
strHTML = strHTML & ""
if strHTML="" Then LoseHTML="":Exit Function
strOutput = objRegExp.Replace(strHTML, "")
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")
strOutput = Replace(strOutput, " ", "")
strOutput = Replace(strOutput, "•", "·")
LoseHTML = Trim(strOutput)
Set objRegExp = Nothing
End Function
<%

Yukarıdaki fonksiyon <%server.htmlencode("deger")%> ile aynı görevi görür. Bu fonksiyonda html tagları sitede görülmez nerede kullanılıyor derseniz bir çok alanda kullanabilirsiniz. Ben kendi sitemde bu fonksiyonu farklı yerlerde kullanıyorum.

Kullanım gayet basit <%=loseHTML("deger")%>
Buradaki değer "

Denemedir
123

" şeklinde gelen degeri denemedir 123 şeklinde gösterir. Umarım anlatabilmişimdir.

Ek Olarak: Buyrun bunlarda benim arşivimden.


<%
Function sifreuret(Uzunluk)
if uzunluk = "" then exit function
Karakterler = "1234567890" '0123456789abcdefghijklmnoprqstuvyzABCDEFGHIJKLMNOPRQSTUVYZ-_
Randomize
KarakterBoyu = Len(Karakterler)
For z = 1 To Uzunluk
KacinciKarakter = Int((KarakterBoyu * Rnd) + 1)
UretilenSifre = UretilenSifre & Mid(Karakterler,KacinciKarakter,1)
Next
sifreuret = UretilenSifre
End Function
%>

<%
Function RemoveSpace(StrSpace)
if StrSpace = "" then exit function
StrSpace = replace(StrSpace, Chr(0), "", 1, -1, 1)
StrSpace = replace(StrSpace, Chr(10), "", 1, -1, 1)
StrSpace = replace(StrSpace, Chr(13), "", 1, -1, 1)
StrSpace = replace(StrSpace, vbCrLf, " ", 1, -1, 1)
RemoveSpace = Trim(StrSpace)
End Function

Function RemoveHTML(strHTML)
On Error Resume Next
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<[^>]*(>|$)"
strHTML = strHTML & ""
If strHTML = "" Then RemoveHTML = "":Exit Function
strHTML = objRegExp.Replace(strHTML, "")
strHTML = Replace(strHTML, " ", " ")
strHTML = Replace(strHTML, "•", " ")
strHTML = Replace(strHTML, """, " ")
strHTML = Replace(strHTML, "<", "<")
strHTML = Replace(strHTML, ">", ">")
RemoveHTML = RemoveSpace(strHTML)
Set objRegExp = Nothing
End Function
%>


<%
Function RemoveText(strText)
nPos1 = InStr(strText, "<")
Do While nPos1 > 0
nPos2 = InStr(nPos1 + 1, strText, ">")
If nPos2 > 0 Then
strText = Left(strText, nPos1 - 1) & Mid(strText, nPos2 + 1)
Else
Exit Do
End If
nPos1 = InStr(strText, "<")
Loop
RemoveText = strText
End Function
%>

<%
function sqlinj(temizle)
if temizle = "" then exit function
temizle = replace (temizle ,"`","",1,-1,1)
temizle = replace (temizle ,"'","",1,-1,1)
temizle = replace (temizle ,"&","",1,-1,1)
temizle = replace (temizle ,"*","",1,-1,1)
temizle = replace (temizle ,"+","",1,-1,1)
temizle = replace (temizle ,"-","",1,-1,1)
temizle = replace (temizle ,"%","",1,-1,1)
temizle = replace (temizle ,"=","",1,-1,1)
temizle = replace (temizle ,"<","",1,-1,1)
temizle = replace (temizle ,">","",1,-1,1)
temizle = replace (temizle ,"(","",1,-1,1)
temizle = replace (temizle ,")","",1,-1,1)
temizle = replace (temizle ,"/","",1,-1,1)
temizle = replace (temizle ,"\","",1,-1,1)
sqlinj = temizle
end function
%>

<%
Function Cevir(Str)
if Str = "" then exit function
Str = Replace(Str, "!", "", 1,-1,0)
Str = Replace(Str, "<", "", 1,-1,0)
Str = Replace(Str, ">", "", 1,-1,0)
Str = Replace(Str, "&", "", 1,-1,0)
Str = Replace(Str, "%", "", 1,-1,0)
Str = Replace(Str, "*", "", 1,-1,0)
Str = Replace(Str, "/", "", 1,-1,0)
Str = Replace(Str, "(", "", 1,-1,0)
Str = Replace(Str, ")", "", 1,-1,0)
Str = Replace(Str, "?", "", 1,-1,0)
Str = Replace(Str, "#", "", 1,-1,0)
Str = Replace(Str, "+", "", 1,-1,0)
Str = Replace(Str, "^", "", 1,-1,0)
Str = Replace(Str, "’", "", 1,-1,0)
Str = Replace(Str, "'", "", 1,-1,0)
Str = Replace(Str, ",", "", 1,-1,0)
Str = Replace(Str, ".", "", 1,-1,0)
Str = Replace(Str, ":", "", 1,-1,0)
Str = Replace(Str, " ", "-", 1,-1,0)
Str = Replace(Str, "ç", "c", 1,-1,0)
Str = Replace(Str, "Ç", "c", 1,-1,0)
Str = Replace(Str, "ğ", "g", 1,-1,0)
Str = Replace(Str, "Ğ", "g", 1,-1,0)
Str = Replace(Str, "ı", "i", 1,-1,0)
Str = Replace(Str, "I", "i", 1,-1,0)
Str = Replace(Str, "İ", "i", 1,-1,0)
Str = Replace(Str, "ö", "o", 1,-1,0)
Str = Replace(Str, "Ö", "o", 1,-1,0)
Str = Replace(Str, "ş", "s", 1,-1,0)
Str = Replace(Str, "Ş", "s", 1,-1,0)
Str = Replace(Str, "ü", "u", 1,-1,0)
Str = Replace(Str, "Ü", "u", 1,-1,0)
Cevir = Str
End Function
%>

<%
Function tren(degistir)
if degistir = "" then exit function
degistir = replace(degistir, "ç", "ç", 1,-1,1)
degistir = replace(degistir, "äÿ", "ğ", 1,-1,0)
degistir = replace(degistir, "ĞŸ", "ğ", 1,-1,0)
degistir = replace(degistir, "ı", "ı", 1,-1,0)
degistir = replace(degistir, "ö", "ö", 1,-1,0)
degistir = replace(degistir, "Åÿ", "ş", 1,-1,0)
degistir = replace(degistir, "ŞŸ", "ş", 1,-1,0)
degistir = replace(degistir, "ü", "ü", 1,-1,0)
degistir = replace(degistir, "Ç", "Ç", 1,-1,0)
degistir = replace(degistir, "Ä", "Ğ", 1,-1,0)
degistir = replace(degistir, "Ö", "Ö", 1,-1,0)
degistir = replace(degistir, "Å", "Ş", 1,-1,0)
degistir = replace(degistir, "Ãœ", "Ü", 1,-1,0)
degistir = replace(degistir, "-", " ", 1,-1,0)
degistir = replace(degistir, "ý", "ı", 1,-1,0)
degistir = replace(degistir, "þ", "ş", 1,-1,0)
degistir = replace(degistir, "ð", "ğ", 1,-1,0)
degistir = replace(degistir, "Ý", "İ", 1,-1,0)
tren = degistir
End Function
%>

<%
Function bosluk(stryeni)
if stryeni = "" then exit function
stryeni = replace(stryeni, vbCrLf, "
", 1, -1, 1)
stryeni = replace(stryeni, Chr(10), "
", 1, -1, 1)
stryeni = replace(stryeni, Chr(13), "
", 1, -1, 1)
stryeni = replace(stryeni, "/n", "
", 1, -1, 1)
bosluk = stryeni
End Function
%>

<%
Function cckemail(email)
if email <> "" Then
Set regex = new regexp
regex.pattern = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
regex.ignorecase = true
If regex.test(email) then cckemail = True else cckemail = false
end If
End Function
%>

<%
function kes(str,max)
max_karakter = max
uzars = "..."
If len(str)>max_karakter Then
yenistr = mid(str,1,max_karakter - len(uzars))
yenistr = yenistr + uzars
else
yenistr = str
End If
kes = yenistr
end function
%>

<%
Function BKarakterYap(byval hedef)
hedef=Replace(hedef,"i" ,"İ" )
hedef=Replace(hedef,"ı" ,"I" )
BKarakterYap = UCase(hedef)
End Function

Function karakterbuyut(byval veri)
dim parcala, k
parcala = Split(veri," ")
For k = 0 To Ubound(parcala)
karakterbuyut = karakterbuyut & BKarakterYap(Left(parcala(k), 1)) & KKarakterYap(Mid(parcala(k), 2))& " "
Next
End Function
%>


<%
Function KKarakterYap(hedef)
hedef = Replace(hedef,"İ" ,"i" )
hedef = Replace(hedef,"I" ,"ı" )
KKarakterYap = LCase(hedef)
End Function
%>

<%
Function ilklerbuyuk(metin)
If metin = "" then exit function
Splitter = " "
If metin <> "" Then
xarr = Split(metin, Splitter)
For i = 0 To UBound(xarr)
xmetin = Trim(xarr(i))

If xmetin <> "" Then
xmetin = LCase(xmetin)
xstletter = UCase(Left(xmetin,1))
xstletter = Replace(xstletter,"i","İ", 1, -1) 'Y
xmetin = Right(xmetin, Len(xarr(i)) - 1)

xmetin = Replace(xmetin,"İ","i", 1, -1) 'Y
xmetin = xstletter & xmetin
End If
zmetin = zmetin & " " & xmetin
Next
End If
ilklerbuyuk = zmetin
end function
%>

<%
Public Function FormatDate(data,hideHour)
If Not IsDate(data) Then Exit Function
gun = Weekday(data)
ay = Month(data)
yil = Year(data)
aygunu = Day(data)
saat = Hour(data)
dakika = Minute(data)
saniye = Second(data)
Dim gunler(7)
gunler(1) = "Pazar"
gunler(2) = "Pazartesi"
gunler(3) = "Salı"
gunler(4) = "Çarşamba"
gunler(5) = "Perşembe"
gunler(6) = "Cuma"
gunler(7) = "Cumartesi"
Dim aylar(12)
aylar(1) = "Ocak"
aylar(2) = "Subat"
aylar(3) = "Mart"
aylar(4) = "Nisan"
aylar(5) = "Mayıs"
aylar(6) = "Haziran"
aylar(7) = "Temmuz"
aylar(8) = "Ağustos"
aylar(9) = "Eylül"
aylar(10) = "Ekim"
aylar(11) = "Kasım"
aylar(12) = "Aralık"
If saat > 12 Then
ampm = "PM"
Else
ampm = "AM"
End If
If hideHour = False Then
t_part = saat & ":" & dakika & ":" & saniye & " " & ampm
Else
t_part = ""
End If
FormatDate = aygunu & " " & aylar(ay) & " " & yil & ", " & gunler(gun) & " " & t_part
End Function
%>

<%
Function kontrol(deger)
If deger = "" then exit function
If isnull(deger) then
kontrol = true
Elseif deger = "" then
kontrol = true
else
kontrol = false
End If
End Function
%>

<%
Function gizle(icerik)
Dizi = split(icerik," ")
For i = 0 to ubound(Dizi)
If instr(lcase(Dizi(i)), "http://") > 0 or instr(lcase(Dizi(i)), "www.") > 0 Then
Response.write "* Linkleri görebilmek için lütfen giriş yapın."
Else
Response.write Dizi(i)
Response.write " "
End if
Next
End Function
%>

<%
Function zamanbul(strveri)
if strveri = "" then exit function
GecenSaniye = DateDiff("s", strveri, Now())
If GecenSaniye = 0 Then
zamanbul = "az önce"
ElseIf gecenSaniye >= 1 And gecenSaniye < 60 Then
zamanbul = ""&gecenSaniye&" saniye önce"
ElseIf gecenSaniye >= 60 And gecenSaniye < 3600 Then
zamanbul = ""&Int(gecenSaniye/60)&" dakika önce "
ElseIf gecenSaniye >= 3600 And gecenSaniye < 86400 Then
zamanbul = ""&Int(gecenSaniye/3600)&" saat önce "
ElseIf gecenSaniye >= 86400 And gecenSaniye < 604800 Then
zamanbul = ""&Int(gecenSaniye/86400)&" gün önce "
ElseIf gecenSaniye >= 604800 And gecenSaniye < 2592000 Then
zamanbul = ""&Int(gecenSaniye/604800)&" hafta önce "
ElseIf gecenSaniye >= 2592000 And gecenSaniye < 31104000 Then
zamanbul = ""&Int(gecenSaniye/2592000)&" ay önce "
ElseIf gecenSaniye >= 31104000 Then
zamanbul = ""&Int(gecenSaniye/31104000)&" yıl önce"
End If
End Function
%>