ASP security detection and filtering function Safecheck
Source: Internet
Author: User
'--------------------------------------------------------------------------
' Role: Secure string detection function
' Name: Safecheck
' Parameter: checkstring,checktype,checklength
Description
' Checkstring to detect string: any character.
' Checktype detection type 0 normal short character 1 digit 2nd period 3 Money 4 encoded HTML5 decoding HTML6 login string 7 anti-attack detection
' Checklength detection type length: type int, position of decimal point when money is
' Return value: If the correct string is returned by detection,
' Return error code if not passed system_error| Error_code
' Script writen by:snowdu (Duche. NET)
' web:http://www.snsites.com/
'--------------------------------------------------------------------------
function Safecheck (checkstring,checktype,checklength)
On Error Resume Next
errorroot= "system_error|"
If checkstring= "" Then
safecheck=errorroot& "00001"
Exit function
End If
Checkstring=replace (checkstring, "'", "& #39")
Select Case Checktype
Case 0
Checkstring=trim (checkstring)
Safecheck=left (Checkstring,checklength)
Case 1
If not isnumberic (checkstring) Then
safecheck=errorroot& "00002"
Exit function
Else
Safecheck=left (Checkstring,checklength)
End If
Case 2
Tempvar=isdate (checkstring)
If not TempVar then
safecheck=errorroot& "00003"
Exit function
Else
Select Case Checklength
Case 0
Safecheck=formatdatetime (Checkstring,vbshortdate)
Case 1
Safecheck=formatdatetime (Checkstring,vblongdate)
Case 2
Safecheck=checkstring
End Select
End If
Case 3
Tempvar=formatcurrency (checkstring,0)
If Err Then
safecheck=errorroot& "00004"
Exit function
Else
Safecheck=formatcurrency (Checkstring,checklength)
End If
Case 4
Stemp = checkstring
If IsNull (stemp) = True Then
safecheck=errorroot& "00005"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service