用户名: 密码: 验证码:           网站地图 高级搜索 RSS订阅 收藏本站
Google
您的位置:首页>>网络编程>>ASP编程>>阅读资讯:ASP开发中有用的函数(function)集合(3)

ASP开发中有用的函数(function)集合(3)

[ 来源: | 阅读:次 | 更新日期:2007-9-29 19:55:30 | 评论 0 条 | 我要投稿 ]

ASP开发中有用的函数(function)集合,挺有用的,请大家保留!

字串7

'*************************************   
'切割内容 - 按行分割   
'*************************************   
Function SplitLines(byVal Content,byVal ContentNums)    
    Dim ts,i,l   
    ContentNums=int(ContentNums)   
    If IsNull(Content) Then Exit Function  
    i=1   
    ts = 0   
    For i=1 to Len(Content)   
      l=Lcase(Mid(Content,i,5))   
        If l="<br/>" Then  
            ts=ts+1   
        End If  
      l=Lcase(Mid(Content,i,4))   

字串5


        If l="<br>" Then  
            ts=ts+1   
        End If  
      l=Lcase(Mid(Content,i,3))   
        If l="<p>" Then  
            ts=ts+1   
        End If  
    If ts>ContentNums Then Exit For    
    Next  
    If ts>ContentNums Then  
        Content=Left(Content,i-1)   
    End If  
    SplitLines=Content   
End Function  
  
月落网

'*************************************   
'切割内容 - 按字符分割   
'*************************************   
Function CutStr(byVal Str,byVal StrLen)   
    Dim l,t,c,i   
    If IsNull(Str) Then CutStr="":Exit Function  
    l=Len(str)   
    StrLen=int(StrLen)   
    t=0   
    For i=1 To l   
        c=Asc(Mid(str,i,1))   
        If c<0 Or c>255 Then t=t+2 Else t=t+1   
        IF t>=StrLen Then  
            CutStr=left(Str,i)"..."  
            Exit For   月落网
        Else  
            CutStr=Str   
        End If  
    Next  
End Function  
  
'*************************************   
'删除引用标签   
'*************************************   
Function DelQuote(strContent)   
    If IsNull(strContent) Then Exit Function  
    Dim re   
    Set re=new RegExp   
    re.IgnoreCase =True  
    re.Global=True  
    re.Pattern="\[quote\](.[^\]]*?)\[\/quote\]"  
    strContent= re.Replace(strContent,"")    字串5
    re.Pattern="\[quote=(.[^\]]*)\](.[^\]]*?)\[\/quote\]"  
    strContent= re.Replace(strContent,"")   
    Set re=Nothing  
    DelQuote=strContent   
End Function  
  
'*************************************   
'获取客户端IP   
'*************************************   
function getIP()    
         dim strIP,IP_Ary,strIP_list   
         strIP_list=Replace(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),"'","")   
            
         If InStr(strIP_list,",")<>0 Then  
字串8

            IP_Ary = Split(strIP_list,",")   
            strIP = IP_Ary(0)   
         Else  
            strIP = strIP_list   
         End IF   
            
         If strIP=Empty Then strIP=Replace(Request.ServerVariables("REMOTE_ADDR"),"'","")   
         getIP=strIP   
End Function  
  
'*************************************   
'获取客户端浏览器信息   
'*************************************    字串9
function getBrowser(strUA)    
 dim arrInfo,strType,temp1,temp2   
 strType=""  
 strUA=LCase(strUA)   
 arrInfo=Array("Unkown","Unkown")   
 '浏览器判断   
    if Instr(strUA,"mozilla")>0 then arrInfo(0)="Mozilla"  
    if Instr(strUA,"icab")>0 then arrInfo(0)="iCab"  
    if Instr(strUA,"lynx")>0 then arrInfo(0)="Lynx"  
    if Instr(strUA,"links")>0 then arrInfo(0)="Links"  
    if Instr(strUA,"elinks")>0 then arrInfo(0)="ELinks"  
    if Instr(strUA,"jbrowser")>0 then arrInfo(0)="JBrowser"  
    if Instr(strUA,"konqueror")>0 then arrInfo(0)="konqueror"  
月落

    if Instr(strUA,"wget")>0 then arrInfo(0)="wget"  
    if Instr(strUA,"ask jeeves")>0 or Instr(strUA,"teoma")>0 then arrInfo(0)="Ask Jeeves/Teoma"  
    if Instr(strUA,"wget")>0 then arrInfo(0)="wget"  
    if Instr(strUA,"opera")>0 then arrInfo(0)="opera"  
  
    if Instr(strUA,"gecko")>0 then    
      strType="[Gecko]"  
      arrInfo(0)="Mozilla"  
      if Instr(strUA,"aol")>0 then arrInfo(0)="AOL"  
      if Instr(strUA,"netscape")>0 then arrInfo(0)="Netscape"  
      if Instr(strUA,"firefox")>0 then arrInfo(0)="FireFox"   月落
      if Instr(strUA,"chimera")>0 then arrInfo(0)="Chimera"  
      if Instr(strUA,"camino")>0 then arrInfo(0)="Camino"  
      if Instr(strUA,"galeon")>0 then arrInfo(0)="Galeon"  
      if Instr(strUA,"k-meleon")>0 then arrInfo(0)="K-Meleon"  
      arrInfo(0)=arrInfo(0)+strType   
   end if   
      
   if Instr(strUA,"bot")>0 or Instr(strUA,"crawl")>0 then    
      strType="[Bot/Crawler]"  
      arrInfo(0)=""  
      if Instr(strUA,"grub")>0 then arrInfo(0)="Grub"   字串9
      if Instr(strUA,"googlebot")>0 then arrInfo(0)="GoogleBot"  
      if Instr(strUA,"msnbot")>0 then arrInfo(0)="MSN Bot"  
      if Instr(strUA,"slurp")>0 then arrInfo(0)="Yahoo! Slurp"  
      arrInfo(0)=arrInfo(0)+strType   
  end if   
     
  if Instr(strUA,"applewebkit")>0 then    
      strType="[AppleWebKit]"  
      arrInfo(0)=""  
      if Instr(strUA,"omniweb")>0 then arrInfo(0)="OmniWeb"  
      if Instr(strUA,"safari")>0 then arrInfo(0)="Safari"  
字串7

      arrInfo(0)=arrInfo(0)+strType   
  end if    
     
  if Instr(strUA,"msie")>0 then    
      strType="[MSIE"  
      temp1=mid(strUA,(Instr(strUA,"msie")+4),6)   
      temp2=Instr(temp1,";")   
      temp1=left(temp1,temp2-1)   
      strType=strType & temp1 "]"  
      arrInfo(0)="Internet Explorer"  
      if Instr(strUA,"msn")>0 then arrInfo(0)="MSN"  
      if Instr(strUA,"aol")>0 then arrInfo(0)="AOL"  
      if Instr(strUA,"webtv")>0 then arrInfo(0)="WebTV"   字串5
      if Instr(strUA,"myie2")>0 then arrInfo(0)="MyIE2"  
      if Instr(strUA,"maxthon")>0 then arrInfo(0)="Maxthon"  
      if Instr(strUA,"gosurf")>0 then arrInfo(0)="GoSurf"  
      if Instr(strUA,"netcaptor")>0 then arrInfo(0)="NetCaptor"  
      if Instr(strUA,"sleipnir")>0 then arrInfo(0)="Sleipnir"  
      if Instr(strUA,"avant browser")>0 then arrInfo(0)="AvantBrowser"  
      if Instr(strUA,"greenbrowser")>0 then arrInfo(0)="GreenBrowser"  
      if Instr(strUA,"slimbrowser")>0 then arrInfo(0)="SlimBrowser"  

月落


      arrInfo(0)=arrInfo(0)+strType   
   end if   
    
 '操作系统判断   
    if Instr(strUA,"windows")>0 then arrInfo(1)="Windows"  
    if Instr(strUA,"windows ce")>0 then arrInfo(1)="Windows CE"  
    if Instr(strUA,"windows 95")>0 then arrInfo(1)="Windows 95"  
    if Instr(strUA,"win98")>0 then arrInfo(1)="Windows 98"  
    if Instr(strUA,"windows 98")>0 then arrInfo(1)="Windows 98"  
    if Instr(strUA,"windows 2000")>0 then arrInfo(1)="Windows 2000"  
    if Instr(strUA,"windows xp")>0 then arrInfo(1)="Windows XP"  
字串8

  
    if Instr(strUA,"windows nt")>0 then   
      arrInfo(1)="Windows NT"  
      if Instr(strUA,"windows nt 5.0")>0 then arrInfo(1)="Windows 2000"  
      if Instr(strUA,"windows nt 5.1")>0 then arrInfo(1)="Windows XP"  
      if Instr(strUA,"windows nt 5.2")>0 then arrInfo(1)="Windows 2003"  
    end if   
    if Instr(strUA,"x11")>0 or Instr(strUA,"unix")>0 then arrInfo(1)="Unix"  
    if Instr(strUA,"sunos")>0 or Instr(strUA,"sun os")>0 then arrInfo(1)="SUN OS"  
    if Instr(strUA,"powerpc")>0 or Instr(strUA,"ppc")>0 then arrInfo(1)="PowerPC"   月落网
    if Instr(strUA,"macintosh")>0 then arrInfo(1)="Mac"  
    if Instr(strUA,"mac osx")>0 then arrInfo(1)="MacOSX"  
    if Instr(strUA,"freebsd")>0 then arrInfo(1)="FreeBSD"  
    if Instr(strUA,"linux")>0 then arrInfo(1)="Linux"  
    if Instr(strUA,"palmsource")>0 or Instr(strUA,"palmos")>0 then arrInfo(1)="PalmOS"  
    if Instr(strUA,"wap ")>0 then arrInfo(1)="WAP"  
     
 'arrInfo(0)=strUA    
 getBrowser=arrInfo   
end function   
共3页: 上一页 1 [2] [3] 下一页
Tags:ASP,函数,function
责任编辑:babylon
您的评论
用户名:新注册) 密码: 匿名评论 [所有评论]

·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任
·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据
·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为