过滤常用的非法字符
<%
\'******************************
\'函数:ReplaceBadChar(strChar)
\'参数:strChar,待过滤字符
\'作者:阿里西西
\'日期:2007/7/12
\'描述:过滤常用的非法字符
\'示例:<%=ReplaceBadChar(\"包含有非法字符的\'*示例\")%>
\'******************************
function ReplaceBadChar(strChar)
if strChar=\"\" then
ReplaceBadChar=\"\"
else
ReplaceBadChar=replace(replace(replace(replace(replace(replace(replace(strChar,\"\'\",\"\"),\"*\",\"\"),\"?\",\"\"),\"(\",\"\"),\")\",\"\"),\"<\",\"\"),\".\",\"\")
end if
end function
%>
[此贴子已经被作者于2007-7-12 13:39:22编辑过]
格式化HTML字符显示
<%
\'******************************
\'函数:HTMLEncode(fString)
\'参数:fString,待格式化字符串
\'作者:阿里西西
\'日期:2007/7/12
\'描述:格式化HTML字符显示
\'示例:<%=HTMLEncode(fString)%>
\'******************************
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, \">\", \">\")
fString = replace(fString, \"<\", \"<\")
fString = Replace(fString, CHR(32), \" \")
fString = Replace(fString, CHR(9), \" \")
fString = Replace(fString, CHR(34), \"\"\")
fString = Replace(fString, CHR(39), \"'\")
fString = Replace(fString, CHR(13), \"\")
fString = Replace(fString, CHR(10) & CHR(10), \" \")
fString = Replace(fString, CHR(10), \" \")
HTMLEncode = fString
end if
end function
%>
生成不重复的随机数,通常应用于静态HTML生成的文件名
<%
\'******************************
\'函数:GetNewFileName
\'参数:无
\'作者:阿里西西
\'日期:2007/7/12
\'描述:生成不重复的随机数,通常应用于静态HTML生成的文件名
\'示例:<%=GetNewFileName()%>
\'******************************
Function GetNewFileName()
dim ranNum
dim dtNow
dtNow=Now()
ranNum=int(90000*rnd)+10000
GetNewFileName=year(dtNow) & right(\"0\" & month(dtNow),2) & right(\"0\" & day(dtNow),2) & right(\"0\" & hour(dtNow),2) & right(\"0\" & minute(dtNow),2) & right(\"0\" & second(dtNow),2) & ranNum
End Function
%>
邮件地址验证函数
<%
\'******************************
\'函数:IsValidEmail(email)
\'参数:email,待验证的邮件地址
\'作者:阿里西西
\'日期:2007/7/12
\'描述:邮件地址验证
\'示例:<%=IsValidEmail([email=alixixi@msn.com)%]alixixi@msn.com)%[/email]>
\'******************************
function IsValidEmail(email)
dim names, name, i, c
IsValidEmail = true
names = Split(email, \"@\")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr(\"abcdefghijklmnopqrstuvwxyz_-.\", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = \".\" or Right(name, 1) = \".\" then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), \".\") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), \".\")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, \"..\") > 0 then
IsValidEmail = false
end if
end function
%> |