收藏的ASP常用的函数集
程序员文章站
2024-02-05 23:08:04
asp函数集 '========取得带端口的url,推荐使用================ function get_scriptnameurl()...
asp函数集
'========取得带端口的url,推荐使用================
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
'=================用正则表达式突出显示字符串中查询到的单词的函数======================
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
'===============取得用户当前ip地址===================
function getip()
uip = request.servervariables("http_x_forwarded_for")
if uip = "" then uip = request.servervariables("remote_addr")
getip = uip
end function
'===============取得当前程序脚本路径==================
function getscriptname()
scriptaddress = cstr(request.servervariables("script_name"))'取得当前地址
if (request.querystring <> "") then
scriptaddress = scriptaddress & "?" & server.htmlencode(request.querystring)'取得带参数地址
end if
if len(scriptaddress)>250 then scriptaddress = left(scirptaddress,250)&"..." '进行路径截取,最大为250个字符
getscriptname = scriptaddress
end function
'===========返回带参数的url,多关键字排序时使用==============
' removelist 参数:需要从url中去除的参数,可以是多个,中间请用逗号隔开
function keepurlstr(removelist)
scriptaddress = cstr(request.servervariables("script_name"))&"?"'取得当前地址,并加入“?”符号
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
'========取得带端口的url,推荐使用================
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
'=================用正则表达式突出显示字符串中查询到的单词的函数======================
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
'===============取得用户当前ip地址===================
function getip()
uip = request.servervariables("http_x_forwarded_for")
if uip = "" then uip = request.servervariables("remote_addr")
getip = uip
end function
'===============取得当前程序脚本路径==================
function getscriptname()
scriptaddress = cstr(request.servervariables("script_name"))'取得当前地址
if (request.querystring <> "") then
scriptaddress = scriptaddress & "?" & server.htmlencode(request.querystring)'取得带参数地址
end if
if len(scriptaddress)>250 then scriptaddress = left(scirptaddress,250)&"..." '进行路径截取,最大为250个字符
getscriptname = scriptaddress
end function
'===========返回带参数的url,多关键字排序时使用==============
' removelist 参数:需要从url中去除的参数,可以是多个,中间请用逗号隔开
function keepurlstr(removelist)
scriptaddress = cstr(request.servervariables("script_name"))&"?"'取得当前地址,并加入“?”符号
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