📄 function.asp
字号:
<%
'#################################################################################
'# SetSafeStr 将字符串转换成用于网页显示和SQL查询的安全字符串
'# 参数:str {即将转换的字符串}
'#
'# 返回:字符串
'#################################################################################
Function SetSafeStr(str)
Dim strResult,iLen,i
If IsNULL(str) Then
SetSafeStr = ""
Exit Function
End If
iLen = Len(str)
strResult = ""
For i = 1 To iLen
Select Case Mid(str,i,1)
Case "<"
strResult = strResult & "<"
Case ">"
strResult = strResult & ">"
Case Chr(13)
strResult = strResult & "<br>"
Case Chr(34)
strResult = strResult & """
Case "&"
strResult = strResult & "&"
Case Chr(32)
strResult = strResult & " "
Case Chr(9)
strResult = strResult & " "
Case Chr(39)
strResult = strResult & ""
Case Else
strResult = strResult & Mid(str,i,1)
End Select
Next 'i
SetSafeStr = strResult
End Function
'#################################################################################
'#################################################################################
'# GetSafeStr 从数据库中得到字符串用于在网页控件中还原显示,适应多行文本
'# 参数:str {数据库里的字符串}
'#
'# 返回:字符串
'#################################################################################
Function GetSafeStr(str)
Dim strResult
strResult = str
strResult = Replace (strResult,"<br>",chr(13))
strResult = Replace (strResult,"''",chr(39))
strResult = Replace (strResult," ",chr(32))
strResult = Replace (strResult,"<center><img src=","[img]")
strResult = Replace (strResult,"></img></center>","[/img]")
strResult = Replace (strResult,"<font color=CC0000>","[red]")
strResult = Replace (strResult,"</font>","[/red]")
strResult = Replace (strResult,"<b>","[b]")
strResult = Replace (strResult,"</b>","[/b]")
strResult = Replace (strResult,"<div align=""center"">","[c]")
strResult = Replace (strResult,"</div>","[/c]")
GetSafeStr = strResult
End Function
'#################################################################################
'############################################################
'# 出错返回子程序
'############################################################
Sub errorMsg(theError)
response.write"<script language=javascript>alert('"& theError &"');history.back();</script>"
response.End
End Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -