**************************************** ***************************
'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 ),"'")
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
Show n character functions on the left (automatically recognize Chinese characters)
Rem displays n characters on the left (automatically recognizing Chinese characters)
Function lefttrue (STR, n)
If Len (STR) <= n/2 then
Lefttrue = Str
Else
L = Len (STR)
T = L
Tstr = ""
T = 0
For I = 1 to L
C = ASC (mid (STR, I, 1 ))
If C <0 then C = C ++ 65536
If C & gt; 255 then
T = T + 2
Else
T = t + 1
End if
If T> N then exit
Tstr = tstr & (mid (STR, I, 1 ))
Next
Lefttrue = tstr
End if
End Function
How to filter HTML tags
I tried a lot of regular expressions and finally found the best effect. Basically, I can filter out all the HTML tags and share them with you.
Public Function removehtml (byval strhtml) as string
Dim pattern = "<(\/\ s *)?!? (\ W + :)? \ W +) (\ W + (\ s * =? \ S * (["" ']) (\ ["" 'tbnr] | [^ \ 7]) *? \ 7 | \ W +) |. {0}) | \ s )*? (\/\ S *)?> "
Strhtml = system. Text. regularexpressions. RegEx. Replace (strhtml, pattern, String. Empty, system. Text. regularexpressions. regexoptions. ignorecase)
Strhtml = strhtml. Replace ("& nbsp ;","")
Return strhtml
End Function
Create folders online using Forms
Using the FSO (FileSystemObject) component of ASP, you can create folders online through forms. Production method:
The content of folder.htm, a single file of the formform table in the HTML format:
<Form name = "form1" method = "Post" Action = "folder-action.asp">
Create a folder
<Input type = "text" name = "name">
<Input type = "Submit" name = "Submit" value = "Submit">
</Form>
ASP FOLDER-ACTION.ASP
<% @ Language = "VBScript" %>
<% Dim name
Name = request ("name ")
Set FS = Createobject ("scripting. FileSystemObject ")
Myfolder = server. mappath ("" & name &"")
If not fs. folderexists (myfolder) then
FS. createfolder (myfolder)
End if
If fs. folderexists (myfolder) then
%> Folder created successfully! Called
<% = Myfolder %>
<%
Else
Response. Write "there has been an error ."
End if
%>