且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

服务器端的adsense

更新时间:2023-11-27 22:13:52

你是正确的,javascript是客户端。但是,它具有与服务器通信的能力。我无法访问此问题中引用的源(它显示为一个空白屏幕),我***使用上面的答案和我自己的javascript知识。

You are correct that javascript is client side. However, it does have abilities to communicate with a server. I'm unable to access the source referenced in this question (it's showing up as a blank screen), I'm forced to work with the answers above and my own knowledge of javascript.

首先,Google广告不会只托管在Google网域网站上。这消除了使用AJAX的任何可能性,而不使用位于正在使用的域中的PHP代理。由于我从未记得在设置Adsense时使用此类代理,因此我可以放心地假设跨域限制(您可以阅读相同的源代码政策此处)将应用(即,来自somedomain.com的javascript文件无法与anotherdomain.com通信,除非使用解决方法),并且.js文件不包含任何对 XMLHttpRequest

First, Google ads are not hosted only on Google domain sites. That removes ANY possibility of using AJAX without a PHP proxy located within the domain being used. As I never remembered using such a proxy when I set up Adsense, I can safely assume that the cross domain limitations (you can read about the same source origin policy here) will apply (i.e. a javascript file from somedomain.com cannot communication to anotherdomain.com, unless using a workaround), and the .js file does not contain any references to XMLHttpRequest. However, there are ways to work around this, not just using the PHP proxy that I noted above.

跨域解决方法:


  1. 使用跟踪像素。我注意到,有人上面说的图像标签在源中看到。代码所做的是生成指向图片文件的链接(例如 www.googleAdTracker.com/trackingPixel.gif?userid=XXX&site=yourSite ),网址将用于标识用户,网站以及Google Adsense需要工作的所有其他参数。或者,它可以捕获用户的IP地址(因为这是与HTTP中的任何事务一起提交的(我可以记住),以及设置Cookie,使Adsense不只是跟踪网站,而是用户。在Firefox中,去工具 - >选项 - >隐私 - >删除单个cookie,你可以查看,搜索和可能的编辑(如果你安装一个特定的插件,我相信)个人的cookie。这就是Google成为隐私群体的目标的方式,他们的广告和他们的Cookie被传播在网络上,他们可以跟踪我做的一切,我去的网站的一般类型,我感兴趣的。不仅仅是这样,Google可以处理到美国***的信息(是的,它这样做,只要搜索它在任何可信的新闻网站),当问及,但也看到我感兴趣,从而提供适用

  2. 第二种解决方法是通过设置iframe。您创建一个新的iframe对象 frame = document.createElement(iframe),然后设置 src iframe到一个URL,这将使他们能够发送一个单向的通信到服务器(嗯,服务器可以回复,但它会在iframe,这将无法从页面中的Javascript代码访问) 。如上所述,请求网址中的参数和iframe的Cookie /内容将启用对用户和网站的跟踪。

  3. 上周,我发现这个有趣的网站一种使用jQuery来解决跨域限制的方法,您可以阅读它这里,但我确定Google Adsense不使用它

  4. 我也听说过使用adobe Flash的解决方法,但问题是并非所有用户都有闪光已安装

  1. Using a tracking pixel. I noticed that someone above said a image tag was seen in the source. What the code does is generate a link to an image file (say www.googleAdTracker.com/trackingPixel.gif?userid=XXX&site=yourSite) and the parameters within the URL will be used to identify the user, the site, and all the other parameters Google Adsense needs to work. Alternatively, it can capture the user's IP address (as this is submitted with any transaction within HTTP (that I can remember)), as well as set cookies that enable Adsense to not just track the website, but the users. In Firefox, to go Tools->Options->Privacy->remove individual cookies, and you can view, search, and possible edit (if you install a certain plugin, I believe) the individual cookies. That's how Google has become a target of privacy groups, their ads and their cookies are spread all over the net, and they can track everything I'm doing, the general type of sites I go to, what I'm interested in. This is not just so Google can handle over info to the U.S. government (yes, it does do that, just search it up on any credible news site) when asked, but also to see what I'm interested in, and thus serve up applicable ads to me.
  2. A second workaround is via the setting of an iframe. You create a new iframe object frame=document.createElement("iframe"), and then set the src value of the iframe to a URL, and that will enable them to send a one way communication to the server (well, the server can reply, but it'll be in the iframe, which will not be accessible from the Javascript code in the page). Like above, the parameters in the request URL, and the cookies/content of the iframe will enable tracking of users and sites.
  3. Last week, I found this interesting site that claims to have found a way using jQuery to work around the cross domain restrictions, you can read about it here, but I'm certain Google Adsense does not use it
  4. I've also heard of workarounds using adobe Flash, but the problem is that not all users have flash installed

回到有关请求的问题。我可以想到(不需要反编译JavaScript代码的页面)的最简单的方法是安装 Live HTTP头到Firefox(如果你没有Firefox,安装它)。我还建议 Firebug ,而不只是针对此项目,因为它是非常有用的。安装Live HTTP标头并重新启动Firefox后,请转到工具 - > Live HTTP标头,然后转到相关网站,即带有广告的网站。然后,您可以转到LHH窗口,并可以准确地查看正在进行的请求,以及浏览器进行的所有幕后通信以及传递到Google Adsense服务器的所有参数。 (如上所述,我没有看到有问题的.js文件的来源,所以我上面说的大部分是从经验和直觉的猜测)。

Back to your question regarding the requests. Simplest way I can think of (without decompiling pages of javascript code) is to install Live HTTP Headers into Firefox (if you don't have Firefox, install it). I suggest Firebug as well, not just for this project, as it is very useful. After you install Live HTTP Headers, and restarted Firefox, go to Tools->Live HTTP Headers, and then go to the site in question, the one with the ads. Then, you can go to the LHH window, and you can see exactly what requests are being made, and all the behind-the-scene communications your browser makes, and all the parameters being passed to the Google Adsense servers. (Like I said above, I haven't seen the source of the .js file in question, so most of what I said above is from experience and intuitive guessing).

现在,你也使用PHP提到过上面的。嗯,当JavaScript与PHP通信,说加载页面: yoursite.com/test.php?foo=bar&testing=123 ,PHP文件接收参数一个变量,存储在 $ _ REQUEST 中的数组中(其他变量保存相同的信息,但这不是我的观点)。例如,上面示例链接中的test.php文件具有包含两个有趣的键和值的 $ _ REQUEST 数组。 $ _ REQUEST ['foo'] 设置为 bar $ _ REQUEST ['testing' ] 设置为 123 。所以,接收PHP文件可以使用这个,如果user_id或 google_ad_client 在URL中,它将在该数组中,并且PHP文件可以处理请求。它也可以访问cookie(cookies数据与请求一起发送),并还跟踪你的方式。此外,客户端的IP地址存储在PHP变量 $ _ SERVER ['REMOTE_ADDR'] 中。所有这些信息可能用于处理和登录数据库(可能是MySQL或类似的东西),并存储在Google服务器上。

Now, you've also mentioned above using PHP. Well, when Javascript communications with PHP, say load up a page: yoursite.com/test.php?foo=bar&testing=123, the PHP file receives the arguments in a variable, stored in an array in $_REQUEST (and other variables hold the same info, but that's not my point). For example, the test.php file in the example link above has the $_REQUEST array containing two interesting keys and values. $_REQUEST['foo'] is set to bar and $_REQUEST['testing'] is set to 123. So, the receiving PHP file can use this, and if the user_id, or google_ad_client was in the URL, it would be in that array, and the PHP file can process the request. It can also access the cookies (cookies data is sent with the request), and also track you down that way. Moreover, the client's IP address is stored in the PHP variable $_SERVER['REMOTE_ADDR']. All this info is probably used in processing and logged in a database (probably MySQL or something similar), and stored on Google servers.

使用这些知识,你可以伪造adsense请求,就像将您从Live HTTP标头通过代理发送到目的地的请求一样(小心,因为Cookie数据难以复制,并且仍然看起来是真实的,并且事实上时间戳可以包括在请求中,有时以加密形式)。这绝对违反服务条款,但我只是给你知识,这是你对你想使用它的选择。

Using this knowledge, you can fake the adsense requests, as in sending the request that you got from Live HTTP Headers via a proxy to the destination (be careful, as cookies data is hard to replicate and still seem authentic, and also the fact that a timestamp may be included within the request, sometimes in encrypted form). It's definitely against the Terms of Service, but I'm only giving you knowledge, it's your choice on what you want to use it on.

在另一个稍微相关的主题,手动发送请求,您可以在浏览器上手动发送GET请求,并使用javascript或PHP发送POST请求。如果你使用PHP,看看cURL。以下是向网站发送POST请求的示例(在这种情况下,我的旧代码使用电子邮件和密码登录Facebook帐户,基本上可以适用于任何网站的任何请求:

On another slightly related subject, to send requests manually, you can send GET requests manually on your browser, and use javascript or PHP to send POST requests. If you're using PHP, look into cURL. Below is an example of sending a POST requests to a site (in this case, it's my old code to log in to a Facebook account using an email and password, can be adapted to basically any request to any site:

$postData = "charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&lsd=" . $lsd . "&locale=en_US&email=" . $login[$i][0] . "&pass=" . $login[$i][5] . "&persistent=1&default_persistent=1&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&lsd=" . $lsd;
$postDataLength = "Content-Length: " . strlen($postData);
$login = curl_init("https://login.facebook.com/login.php?login_attempt=1");
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE); 
curl_setopt($login, CURLOPT_COOKIEFILE, "FBcookies.txt"); 
curl_setopt($login, CURLOPT_COOKIEJAR, "FBcookies.txt"); 
curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13");
curl_setopt($login, CURLOPT_ENCODING, "gzip,deflate"); 
curl_setopt($login, CURLOPT_REFERER, "http://www.facebook.com/"); 
curl_setopt($login, CURLOPT_POSTFIELDS, $postData); 
curl_setopt($login, CURLOPT_HTTPHEADER, array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: en-us,en;q=0.5', 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'Content-Type: application/x-www-form-urlencoded', $postDataLength ));  
$response = curl_exec($login);
curl_close($login);

阅读更多关于CURL

Read more about CURL here. Link to contact me if you want to notify me if anything above is unclear and I need to elaborate more.

作为最后一点,这里是我的免责声明,如果你想通知我上面的任何不清楚, :我从来没有试图发送假的adsense标头,我不鼓励你这样做。我也不负责任何身体伤害,死亡或致残,可能发生在你,你的财产,你的电脑,你的Google帐户,你的一般福利,或你的幸福,使用上述知识。认为我已经安全地覆盖了我自己背后的声明。任何其他问题,只是让我知道使用上面的联系链接。

As a final note, here's my Disclaimer: "I have NEVER tried to send fake adsense headers, and I'm not encouraging you to do so. I am also not responsible for any physical injury, death, or maiming that may happen to you, your possessions, your computer, your Google account, your general well being, or your happiness that occurs from the use of the above knowledge." I think I've safely covered my own behind with that statement. Any more questions, just let me know using that contact link above.