ASP Common Function Collection

Source: Internet
Author: User
Tags filter date exit chr get ip return window client
Function

************************************
' Get IP Address
'************************************
Function Userip ()
Dim Getclientip
' If the client uses a proxy server, you should use the ServerVariables (' Http_x_forwarded_for ') method
Getclientip = Request.ServerVariables ("Http_x_forwarded_for")
If Getclientip = "" or IsNull (Getclientip) or IsEmpty (Getclientip) Then
' If the client does not use an agent, you should use the Request.ServerVariables (' remote_addr ') method
Getclientip = Request.ServerVariables ("REMOTE_ADDR")
End If
Userip = Getclientip
End Function

'************************************
' Convert IP Address
'************************************
function CIP (SIP)
TIP=CSTR (SIP)
Sip1=left (Tip,cint (InStr (Tip, ".") -1))
Tip=mid (Tip,cint (InStr (Tip, ".") +1))
Sip2=left (Tip,cint (InStr (Tip, ".") -1))
Tip=mid (Tip,cint (InStr (Tip, ".") +1))
Sip3=left (Tip,cint (InStr (Tip, ".") -1))
Sip4=mid (Tip,cint (InStr (Tip, ".") +1))
Cip=cint (SIP1) *256*256*256+cint (SIP2) *256*256+cint (SIP3) *256+cint (SIP4)
End Function

'************************************
' Pop-up dialog box
'************************************
SUB Alert (message)
message = replace (message, "'", "\")
Response.Write ("<script>alert" (' & Message & ') </script> ")
End Sub

'************************************
' Returns to the previous page, generally used to determine whether the information is submitted completely
'************************************
Sub GoBack ()
Response.Write ("<script>history.go ( -1) </script>")
End Sub

'************************************
' Redirect Additional connections
'************************************
Sub Go (URL)
Response.Write ("<script>location.href (' & URL & ') </script>")
End Sub

'************************************
' Specifies the number of seconds to redirect additional connections
'************************************
Sub Gopage (url,s)
s=s*1000
Response.Write "<script language=javascript>"
Response.Write "Window.settimeout (&CHR) &" Window.navigate (' "&url&") "&CHR (+) &", " &s& ")"
Response.Write "</script>"
End Sub

'************************************
' Judge if the numbers are shaped
'************************************
function Isinteger (para)
On Error Resume Next
Dim str
Dim l,i
If ISNULL (para) Then
Isinteger=false
Exit function
End If
STR=CSTR (para)
If trim (str) = "" Then
Isinteger=false
Exit function
End If
L=len (str)
For I=1 to L
If Mid (str,i,1) > "9" or mid (str,i,1) < "0" then
Isinteger=false
Exit function
End If
Next
Isinteger=true
If Err.number<>0 then Err.Clear
End Function

'************************************
' Get file name extension
'************************************
function getextend (filename)
Dim tmp
If filename<> "" Then
Tmp=mid (Filename,instrrev (FileName, ".") +1,len (filename)-instrrev (filename, "."))
Tmp=lcase (TMP)
If InStr (1,tmp, "ASP") >0 or InStr (1,tmp, "PHP") >0 or InStr (1,tmp, "php3") >0 or InStr (1,tmp, "aspx") >0 Then
getextend= "TXT"
Else
Getextend=tmp
End If
Else
Getextend= ""
End If
End Function

' *-------------------------------------------
' * Function: CheckIn
' * Description: Detection parameters are SQL dangerous characters
' * parameter: STR data to be detected
' * Return: FALSE: safe TRUE: unsafe
' * Author:
' * Date:
' *-------------------------------------------
function CheckIn (str)
If InStr (1,STR,CHR) >0 or InStr (1,STR,CHR) >0 or InStr (1,STR,CHR) >0
Checkin=true
Else
Checkin=false
End If
End Function

' *-------------------------------------------
' * Function: HTMLEncode
' * Description: Filter HTML code
' * Parameter:--
' * Return:--
' * Author:
' * Date:
' *-------------------------------------------
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 (a) & CHR (a), "</P><P>")
fstring = Replace (fstring, CHR (), "<BR>")

HTMLEncode = fstring
End If
End Function

' *-------------------------------------------
' * Function: Htmlcode
' * Description: Filter form characters
' * Parameter:--
' * Return:--
' * Author:
' * Date:
' *-------------------------------------------
function Htmlcode (fstring)
If not IsNull (fstring) Then
fstring = Replace (fstring, CHR (13), "")
fstring = Replace (fstring, CHR (a) & CHR (a), "</P><P>")
fstring = Replace (fstring, CHR (34), "")
fstring = Replace (fstring, CHR (), "<BR>")
Htmlcode = fstring
End If
End Function



Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.