• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

一个asp替换函数img里面多余的代码

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
<%
Response.Write(Server.HTMLEncode(FixImg("<img onclick=""if(this.width&gt;screen.width-461) window.open('qq/20082181405371.jpg');"" alt="""" border=""0"" src=""qq/20082181405371.jpg"" />")))
%>
<%
'功能:将IMG代码格式化为<img src="XXX" />格式.
Function FixImg(sString)

    Dim sReallyDo, regEx, iReallyDo
    Dim oMatches, cMatch
    Dim tStartTime, tEndTime
    If IsNull(sString) Then
        FixImg = ""
        Exit Function
    End If
    sReallyDo = sString
    On Error Resume Next
    sReallyDo = Replace(sReallyDo, vbCr, " ")
    sReallyDo = Replace(sReallyDo, vbLf, " ")
    sReallyDo = Replace(sReallyDo, vbTab, " ")
    sReallyDo = Replace(sReallyDo, "<img ", vbCrLf & "<img ", 1, -1, 1)
    sReallyDo = Replace(sReallyDo, "/>", " />", 1, -1, 1)
    sReallyDo = ReplaceAll(sReallyDo, "= ", "=", True)
    sReallyDo = ReplaceAll(sReallyDo, "> ", ">", True)
    sReallyDo = Replace(sReallyDo, "><", ">" & vbCrLf & "<")
    sReallyDo = Trim(sReallyDo)
    On Error GoTo 0
    Set regEx = New RegExp
    regEx.IgnoreCase = True
    regEx.Global = True
    '//去除onclick,onload等脚本
    regEx.Pattern = "\s[on].+?=([\""|\'])(.*?)\1"
    sReallyDo = regEx.Replace(sReallyDo, "")
    '//将SRC不带引号的图片地址加上引号
    regEx.Pattern = "<img.*?\ssrc=([^\""\'\s][^\""\'\s>]*).*?>"
    sReallyDo = regEx.Replace(sReallyDo, "<img src=""$1"" />")
    '//正则匹配图片SRC地址
    regEx.Pattern = "<img.*?\ssrc=([\""\'])([^\""\']+?)\1.*?>"
    sReallyDo = regEx.Replace(sReallyDo, "<img src=""$2"" />")
    FixImg = sReallyDo
End Function
%>
<%
'功能:返回字符串,其中指定数目的某子字符串 全部 被替换为另一个子字符串。
'来源:http://jorkin.reallydo.com/article.asp?id=406
'需要Bint函数:http://jorkin.reallydo.com/article.asp?id=395

Function ReplaceAll(sExpression, sFind, sReplaceWith, bAll)
    If IsNull(sExpression) Then ReplaceAll = "" : Exit Function
    If (StrComp(bAll, "True", 1) = 0) Or (CBool(Bint(bAll)) = True) Then
        Do While InStr( 1, sExpression, sFind, 1) > 0
            sExpression = Replace(sExpression, sFind, sReplaceWith, 1, -1, 1)
            If InStr( 1, sReplaceWith , sFind , 1) >0 Then Exit Do
        Loop
    Else
        Do While InStr(sExpression, sFind) > 0
            sExpression = Replace(sExpression, sFind, sReplaceWith)
            If InStr(sReplaceWith, sFind ) > 0 Then Exit Do
        Loop
    End If
    ReplaceAll = sExpression
End Function
%>
<%
'功能:只取数字
'来源:http://jorkin.reallydo.com/article.asp?id=395

Function Bint(Str)
    Str = Trim(Str)
    If Str = "" Or IsNull(Str) Or Not IsNumeric(Str) Then Str = "0"
    Bint = Round(Str, 0)
End Function
%>

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
无服务器做任意二级米子站发布时间:2022-02-05
下一篇:
几种另类的ASP后门发布时间:2022-02-05
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap