Asp/js Functions

Source: Internet
Author: User
Tags servervariables
'********************************** *********************************
'Check if it is mobile browsing
'*************************************** ****************************
<%
If instr (request. ServerVariables ("HTTP_USER_AGENT"), "Mozilla") = 0 then
Response. redirect "/wap" 'If the client is accessed by a mobile phone, enter the/wap directory.
Else
Response. redirect "http://wap.fz0132.com" 'enter the specified address if the client is not accessed by the phone
End if
%> '************************************* ******************************
'Get the IP address
'*************************************** ****************************
Function Userip ()
Dim GetClientIP
'If the client uses a proxy server, use the ServerVariables ("HTTP_X_FORWARDED_FOR") method.
GetClientIP = Request. ServerVariables ("HTTP_X_FORWARDED_FOR ")
If GetClientIP = "" or isnull (GetClientIP) or isempty (GetClientIP) Then
'The Request. ServerVariables ("REMOTE_ADDR") method should be used if no proxy is used on the client.
GetClientIP = Request. ServerVariables ("REMOTE_ADDR ")
End if
Userip = GetClientIP
End function
'*************************************** ****************************
'Dialog box
'*************************************** ****************************
Sub alert (message)
Message = replace (message ,"'","\'")
Response. Write ("<script> alert ('" & message & "') </script> ")
End Sub '************************************* ******************************
'Back to the previous page, generally used after determining whether the information is completely submitted
'*************************************** ****************************
Sub GoBack ()
Response. write ("<script> history. go (-1) </script> ")
End Sub '************************************* ******************************
'Redirect another connection
'*************************************** ****************************
Sub Go (url)
Response. write ("<script> location. href ('" & url & "') </script> ")
End Sub '************************************* ******************************
'Specify the number of seconds to redirect another connection
'*************************************** ****************************
Sub GoPage (url, s)
S = s * 1000
Response. Write "<script language = JavaScript>"
Response. write "window. setTimeout ("& chr (34) &" window. navigate ('"& url &"') "& chr (34) &", "& s &")"
Response. Write "</script>"
End sub '************************************* ******************************
'Judge whether the number is shaping
'*************************************** ****************************
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 the file extension
'*************************************** ****************************
Function GetExtend (filename)
Dim tmp
If filename <> "" then
Tmp = mid (filename, limit Rev (filename, ".") + 1, len (filename)-limit Rev (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: checks whether the parameter has SQL dangerous characters.
'* Parameter: str data to be detected
'* Return: FALSE: Security TRUE: insecure
'* Author:
'* Date:
'*----------------------------------------------------------------------------
Function CheckIn (str)
If instr (1, str, chr (39)> 0 or instr (1, str, chr (34)> 0 or instr (1, str, chr (59)> 0 then
CheckIn = true
Else
CheckIn = false
End if
End function '*----------------------------------------------------------------------------
'* Function: HTMLEncode
'* Description: filters HTML code.
'* Parameter :--
'* Return :--
'* Author:
'* Date:
'*----------------------------------------------------------------------------
Function HTMLEncode (fString)
If not isnull (fString) then
FString = replace (fString, ">", "& gt ;")
FString = replace (fString, "<", "& lt ;")

FString = Replace (fString, CHR (32), "& nbsp ;")
FString = Replace (fString, CHR (9), "& nbsp ;")
FString = Replace (fString, CHR (34), "& quot ;")
FString = Replace (fString, CHR (39), "& #39 ;")
FString = Replace (fString, CHR (13 ),"")
FString = Replace (fString, CHR (10) & CHR (10), "</P> <P> ")
FString = Replace (fString, CHR (10), "<BR> ")

HTMLEncode = fString
End if
End function '*----------------------------------------------------------------------------
'* Function: HTMLcode
'* Description: used to filter form characters.
'* Parameter :--
'* Return :--
'* Author:
'* Date:
'*----------------------------------------------------------------------------
Function HTMLcode (fString)
If not isnull (fString) then
FString = Replace (fString, CHR (13 ),"")
FString = Replace (fString, CHR (10) & CHR (10), "</P> <P> ")
FString = Replace (fString, CHR (34 ),"")
FString = Replace (fString, CHR (10), "<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.