404伪静态函数类

 
<%  
'404伪静态专用函数类 
  
Class Html404  
private regUrl, url  
'作用:获取协议 
  
Public Property Get Pertrol()  
    Pertrol = searchStr(2)  
End Property  
'作用:获取域名 
  
Public Property Get Domain()  
    Domain = searchStr(4)  
End Property  
'作用:获取端口 
  
Public Property Get Port()  
    Port = searchStr(6)  
End Property  
'作用:获取路径 
  
Public Property Get Path()  
    Path = searchStr(9)  
End Property  
'作用:获取参数 
  
Public Property Get Strings()  
    Strings = searchStr(11)  
End Property  
'作用:获取文件名 
  
Public Property Get fname()  
    Dim bAry  
    If Instr(searchStr(9),"/") > 0 Then  
        bAry = Split(searchStr(9),"/")  
        fname = bAry(ubound(bAry))  
    Else  
        fname = searchStr(9)  
    End If  
End Property  
Private Sub Class_Initialize()  
    regUrl = "((http|ftp|https)\:\/\/)(([^\s\:\?\/]+)(\:([\d]+))?(\/(([^\s\?]+)?(\?([^\s]+))?)?)?)?"  
    url = Split(Request.QueryString,";")(1)  
End Sub  
Private Sub Class_Terminate()  
End Sub  
Private Function searchStr(index)  
    Dim objRegExp  
    Set objRegExp=  New RegExp  
    objRegExp.IgnoreCase = True  
    objRegExp.Global = True  
    objRegExp.Pattern = regUrl  
    searchStr = objRegExp.Replace(url, "{1}quot; & index)  
    Set objRegExp = Nothing  
End Function  
'作用:匹配正则,返回匹配替换后的url 
  
'参数:source,要搜索的字串;regFrom,要匹配的正则;regTo,要替换匹配内容的字串 
  
Public Function isAPI(byval source,ByVal regFrom,byval regTo)  
    Dim objRegExp, Match, Matches  
    Set objRegExp = New RegExp  
    Dim str: str = source  
    objRegExp.IgnoreCase = True  
    objRegExp.Global = True  
    objRegExp.Pattern = regFrom  
    str = objRegExp.Replace(str, regTo)  
    Set objRegExp = Nothing  
    isAPI = str  
End Function  
'作用:获取参数 
  
Function getString(index)  
    Dim str  
    str = Split(fname,".")(0)  
    If Instr(str,"_") > 0 Then  
        getString = Split(str,"_")(index)  
    Else  
        getString = ""  
    End If  
End Function  
'作用:获取参数个数,参数是以_来分隔的 
  
Function vCount()  
    Dim str  
    str = Split(fname,".")(0)  
    If Instr(str,"_") > 0 Then  
        vCount  = ubound(Split(str,"_"))  
    Else  
        vCount = 0  
    End If  
End Function  
'作用:错误后跳转到url 
  
Public Function Redir(url,Desc)  
    Response.write&"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"&vbcrlf & _  
                "<html xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""zh-cn"" lang=""zh-cn"">"&vbcrlf & _  
                " <head>"&vbcrlf & _  
                "     <meta http-equiv=""Content-Type"" content=""text/html; charset=UTF8"" />"&vbcrlf & _  
                "     <meta http-equiv=""Refresh"" content=""3;URL=" & url & """ />"&vbcrlf & _  
                "     <title>请稍候,转向中...</title>"&vbcrlf & _  
                " </head>"&vbcrlf & _  
                " <body>" & Desc & ":3秒后转向" & url & "...</body></html>"&vbcrlf  
End Function  
End Class  
%> 

你可能感兴趣的:(html,XHTML,function,url,Class,domain)