ASP set of Functions

Source: Internet
Author: User
Tags functions servervariables
function ' ======== get the URL with port, recommend to use ================
Function Get_scriptnameurl ()
If Request.ServerVariables ("server_port") = "Then"
Get_scriptnameurl= "http://" & Request.ServerVariables ("SERVER_NAME") &lcase ("Request.ServerVariables" Script_name "))
Else
Get_scriptnameurl= "http://" & Request.ServerVariables ("SERVER_NAME") & ":" &request.servervariables (" Server_port ") &lcase (Request.ServerVariables (" Script_name "))
End If
End Function



' ================= a function that uses regular expressions to highlight the words that are queried in the string ======================
Function Boldword (Strcontent,word)
If word= "" Then
Boldword = strcontent
Exit Function
End IF
Dim objregexp
Set objregexp=new REGEXP
Objregexp.ignorecase =true
Objregexp.global=true

Objregexp.pattern= "(& Word &)"
Strcontent=objregexp.replace (strcontent, "<font color=" "#FF0000" "><b>$1</b></font>")

Set objregexp=nothing
Boldword=strcontent
End Function



' =============== gets the user's current IP address ===================
Function GetIP ()
UIP = Request.ServerVariables ("Http_x_forwarded_for")
If UIP = "" Then UIP = Request.ServerVariables ("REMOTE_ADDR")
GetIP = UIP
End Function

' =============== Gets the current program script path ==================
Function Getscriptname ()
scriptaddress = CStr (Request.ServerVariables ("Script_name")) ' Get current address
If (Request.QueryString <> "") Then
scriptaddress = scriptaddress & "?" & Server.HTMLEncode (Request.QueryString) ' Get with parameter address
End If
If Len (scriptaddress) >250 Then scriptaddress = Left (scirptaddress,250) & "..." ' For path interception, maximum 250 characters
Getscriptname = scriptaddress
End Function




' =========== returns a URL with parameters, using ============== when sorting multiple keywords
' removelist parameter: A parameter that needs to be removed from the URL, which can be multiple, separated by commas in the middle
Function Keepurlstr (removelist)
scriptaddress = CStr (Request.ServerVariables ("Script_name")) & "?" Get the current address and add "?" Symbol
M_itemurl = ""
For each m_item in Request.QueryString
If InStr (removelist,m_item) =0 Then
M_itemurl = M_itemurl & m_item & "=" & Server.URLEncode (Request.QueryString ("" &M_Item& ")) &" & "
End If
Next
Keepurlstr = scriptaddress & M_itemurl
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.