Several common ASP Functions

Source: Internet
Author: User

======== Get the URL with a port, we recommend using ==========================
Function get_scriptnameurl ()
If request. servervariables ("server_port") = "80" 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

'======================== Use a regular expression to highlight the function of displaying the words 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

'====================== Obtain the current IP address of the user ==========================
Function getip ()
UIP = request. servervariables ("http_x_forwarded_for ")
If UIP = "" Then UIP = request. servervariables ("remote_addr ")
Getip = UIP
End Function

'================== obtain the script path of the current Program ==== ===============< br> function getscriptname ()
scriptaddress = CSTR (request. servervariables ("script_name") 'gets the current address
If (request. querystring <> "") Then
scriptaddress = scriptaddress &"? "& Server. htmlencode (request. querystring) 'Get the address with parameters
end if
If Len (scriptaddress)> 250 then scriptaddress = left (scirptaddress, 250 )&"... "'path truncation, up to 250 characters
getscriptname = scriptaddress
end function

'=========== return a URL with parameters, when sorting multiple keywords, use =================< br> 'removelist parameter: parameters to be removed from the URL, which can be multiple, separate them with commas (,)
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

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.