人非木

大丈夫处世,不能立功建业,几与草木同腐乎?

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


 


 

 

posted on 2007-11-30 09:35  人非木  阅读(411)  评论(0编辑  收藏  举报

导航