• 正确添加Google Adsense


    <%

    Function googleColor(value, random)
      Dim colorArray
      colorArray = Split(value, ",")
      googleColor = colorArray(random Mod (UBound(colorArray) + 1))
    End Function

    Dim googleTime, googleDt, googleScheme, googleHost
    googleTime = DateDiff("s", "01/01/1970 00:00:00", Now())
    googleDt = (1000 * googleTime) + Round(1000 * (Timer - Int(Timer)))
    googleScheme = "http://"
    if StrComp(Request.ServerVariables("HTTPS"), "on") = 0 Then googleScheme = "https://"
    googleHost = Server.URLEncode(googleScheme & Request.ServerVariables("HTTP_HOST"))

    Dim googleAdUrl, googleAdOutput
    googleAdUrl = "http://pagead2.googlesyndication.com/pagead/ads?" &_
      "ad_type=text" &_
      "&channel=0665447909" &_
      "&client=ca-mb-pub-7160831477832193" &_
      "&dt=" & googleDt &_
      "&format=mobile_double" &_
      "&host=" & googleHost &_
      "&ip=" & Server.URLEncode(Request.ServerVariables("REMOTE_ADDR")) &_
      "&markup=wml" &_
      "&output=wml" &_
      "&ref=" & Server.URLEncode(Request.ServerVariables("HTTP_REFERER")) &_
      "&url=" & googleHost & Server.URLEncode(Request.ServerVariables("URL")) &_
      "&useragent=" & Server.URLEncode(Request.ServerVariables("HTTP_USER_AGENT"))

    Set googleAdOutput = Server.CreateObject("MSXML2.ServerXMLHTTP")
    googleAdOutput.Open "GET", googleAdUrl, false
    googleAdOutput.Send
    Response.Write(googleAdOutput.responseText)

    %>

    我加后 nanyin.mobi

    代码变为:

    <%

    Function googleColor(value, random)
     Dim colorArray
     colorArray = Split(value, ",")
     googleColor = colorArray(random Mod (UBound(colorArray) + 1))
    End Function

    Dim googleTime, googleDt, googleScheme, googleHost
    googleTime = DateDiff("s", "01/01/1970 00:00:00", Now())
    googleDt = (1000 * googleTime) + Round(1000 * (Timer - Int(Timer)))
    googleScheme = "http://"
    if StrComp(Request.ServerVariables("HTTPS"), "on") = 0 Then googleScheme = "https://"
    googleHost = Server.URLEncode(googleScheme & Request.ServerVariables("HTTP_HOST"))

    Dim googleAdUrl, googleAdOutput
    googleAdUrl = "http://pagead2.googlesyndication.com/pagead/ads?" &_
     "ad_type=text" &_
     "&channel=0665447909" &_
     "&client=ca-mb-pub-7160831477832193" &_
     "&dt=" & googleDt &_
     "&format=mobile_double" &_
     "&host=" & googleHost &_
     "&ip=" & Server.URLEncode(Request.ServerVariables("REMOTE_ADDR")) &_
     "&markup=wml" &_
     "&output=wml" &_
     "&ref=" & Server.URLEncode(Request.ServerVariables("HTTP_REFERER")) &_
     "&url=" & googleHost & Server.URLEncode(Request.ServerVariables("URL")) &_
     "&useragent=" & Server.URLEncode(Request.ServerVariables("HTTP_USER_AGENT"))

    Set googleAdOutput = Server.CreateObject("MSXML2.ServerXMLHTTP")
    googleAdOutput.Open "GET", googleAdUrl, false
    googleAdOutput.Send
    Response.Write(googleAdOutput.responseText)

    %>

     

    做成一个函数,加在代码中间,这里是html\vbsvm\classes\mocom\WAPmo\WAP\index.asp为例

    打开index.asp后,在36行,即If blnParse Then下加入下面一段代码

    MyXML.Println MyXML.createT(GoogleAds())

    然后在html\xfunc.asp中加入这段代码

    Function GoogleAds()
        Dim googleTime, googleDt, googleScheme, googleHost
        googleTime = DateDiff("s", "01/01/1970 00:00:00", Now())
        googleDt = (1000 * googleTime) + Round(1000 * (Timer - Int(Timer)))
        googleScheme = "http://"
        if StrComp(Request.ServerVariables("HTTPS"), "on") = 0 Then googleScheme = "https://"
        googleHost = Server.URLEncode(googleScheme & Request.ServerVariables("HTTP_HOST"))

        Dim googleAdUrl, googleAdOutput
        googleAdUrl = "http://pagead2.googlesyndication.com/pagead/ads?" &_
          "ad_type=text" &_
          "&channel=0665447909" &_
          "&client=ca-mb-pub-7160831477832193" &_
          "&dt=" & googleDt &_
          "&format=mobile_double" &_
          "&host=" & googleHost &_
          "&ip=" & Server.URLEncode(Request.ServerVariables("REMOTE_ADDR")) &_
          "&markup=wml" &_
          "&output=wml" &_
          "&ref=" & Server.URLEncode(Request.ServerVariables("HTTP_REFERER")) &_
          "&url=" & googleHost & Server.URLEncode(Request.ServerVariables("URL")) &_
          "&useragent=" & Server.URLEncode(Request.ServerVariables("HTTP_USER_AGENT"))
       
        Dim ret
        Set googleAdOutput = Server.CreateObject("MSXML2.ServerXMLHTTP")
        googleAdOutput.Open "GET", googleAdUrl, false
        googleAdOutput.Send
        ret = googleAdOutput.responseText
        Set googleAdOutput = Nothing
       
        Dim reg
        Set reg = New RegExp
        reg.Pattern = "<p>([\s\S]+?)</p>"
        reg.Global = True
        GoogleAds = reg.Replace(ret, "$1<br/>")
        Set reg = Nothing
    End Function


    googleColor这段函数没发现用到的地方,可以不加
     


     


     

  • 相关阅读:
    选择排序遇到的引用和传值问题记录
    The web application [ROOT] appears to have started a thread named [spring.cloud.inetutils] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
    IDEA中实用的插件
    Column 'status' specified twice
    Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'dataType' in 'field list'
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where id = 2' at line 8
    Missing URI template variable 'id' for method parameter of type long
    值传递和引用传递的区别
    SpringBoot项目与数据库交互,访问http://localhost:8888/admin/userInfo时,报org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
    SpringBoot项目启动时报错:org.apache.catalina.LifecycleException: Protocol handler start failed
  • 原文地址:https://www.cnblogs.com/melonlee/p/977839.html
Copyright © 2020-2023  润新知