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这段函数没发现用到的地方,可以不加
     


     


     

  • 相关阅读:
    函数
    函数
    day---07 文件的操作
    作业9 DFA最小化,语法分析初步
    作业8 非确定的自动机NFA确定化为DFA
    作业7 正规式到正规文法与自动机
    作业6 正规文法与正规式
    作业5 词法分析程序的设计与实现
    作业四 文法和语言总结与梳理
    作业三 语法树,短语,直接短语,句柄
  • 原文地址:https://www.cnblogs.com/melonlee/p/977839.html
Copyright © 2011-2022 走看看