zoukankan      html  css  js  c++  java
  • 正确添加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这段函数没发现用到的地方,可以不加
     


     


     

  • 相关阅读:
    前端与算法 leetcode 344. 反转字符串
    JavaScript闭包使用姿势指南
    前端与算法 leetcode 48. 旋转图像
    前端与算法 leetcode 36. 有效的数独
    前端与算法 leetcode 1. 两数之和
    前端与算法 leetcode 283. 移动零
    前端与编译原理 用js去运行js代码 js2run
    前端与算法 leetcode 66. 加一
    前端与算法 leetcode 350. 两个数组的交集 II
    前端与算法 leetcode 26. 删除排序数组中的重复项
  • 原文地址:https://www.cnblogs.com/melonlee/p/977839.html
Copyright © 2011-2022 走看看