ASP函數集
'========取得帶端口的URL,推薦使用================
FunctionGet_ScriptNameUrl()
Ifrequest.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"))
EndIf
EndFunction
'=================用正則表達式突出顯示字符串中查詢到的單詞的函數======================
FunctionBoldWord(strContent,word)
Ifword=""Then
BoldWord=strContent
ExitFunction
EndIF
dimobjRegExp
SetobjRegExp=newRegExp
objRegExp.IgnoreCase=true
objRegExp.Global=True
objRegExp.Pattern="("&word&")"
strContent=objRegExp.Replace(strContent,"<fontcolor=""#FF0000""><b>$1</b></font>")
SetobjRegExp=Nothing
BoldWord=strContent
EndFunction
'===============取得用戶當前IP地址===================
FunctionGetIP()
uIP=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
IfuIP=""ThenuIP=Request.ServerVariables("REMOTE_ADDR")
GetIp=uIP
EndFunction
'===============取得當前程序腳本路徑==================
FunctionGetScriptName()
ScriptAddress=CStr(Request.ServerVariables("SCRIPT_NAME"))'取得當前地址
If(Request.QueryString<>"")Then
ScriptAddress=ScriptAddress&"?"&Server.HTMLEncode(Request.QueryString)'取得帶參數地址
EndIf
IfLen(ScriptAddress)>250ThenScriptAddress=Left(ScirptAddress,250)&"..."'進行路徑截取,最大為250個字符
GetScriptName=ScriptAddress
EndFunction
'===========返回帶參數的Url,多關鍵字排序時使用==============
'RemoveList參數:需要從Url中去除的參數,可以是多個,中間請用逗號隔開
FunctionKeepUrlStr(RemoveList)
ScriptAddress=CStr(Request.ServerVariables("SCRIPT_NAME"))&"?"'取得當前地址,並加入“?”符號
M_ItemUrl=""
ForEachM_itemInRequest.QueryString
IfInStr(RemoveList,M_Item)=0Then
M_ItemUrl=M_ItemUrl&M_Item&"="&Server.URLEncode(Request.QueryString(""&M_Item&""))&"&"