简体   繁体   English

如何检查网页是否已实际加载?

[英]How to check if the webpage has actually been loaded?

I have an affiliate tracking script that is currently being exploited by an affiliate. 我有一个会员跟踪脚本,当前会员正在利用该脚本。 In the main, site I track the affiliate clicks using this url www.example.com?member=affiliatecode, then I capture the query string $_GET['member']; 在主要的网站中,我使用以下网址www.example.com?member=affiliatecode跟踪会员点击,然后捕获查询字符串$ _GET ['member'];。

Problem is, an affiliate is exploiting this simple system and page loads on his site is being recorded as clicks going to mine. 问题是,一个会员正在利用这个简单的系统,并且他的站点上的页面负载被记录为要挖掘的点击。

What measures can I add to prevent this without changing the affiliate link to my site? 在不更改我网站的会员链接的情况下,我可以采取哪些措施来防止这种情况? An idea that I had is to check if my page has actually been loaded, but how would I do that in PHP? 我的想法是检查页面是否已实际加载,但是我将如何在PHP中执行此操作?

Thanks 谢谢

I don't quite grasp the exact problem (or more to the point, exactly how the affiliate is logging hits), but a solution may be to put a image on your page which should ensure that a browser has loaded it. 我不太了解确切的问题(或更确切地说,是会员如何记录点击数),但是一种解决方案可能是在页面上放置图片,以确保浏览器已加载图片。 So at the bottom of you page you should insert 因此,您应该在页面底部插入

<?
if ( isset($_GET['affiliate']) ){
    echo '<img src="affimg.php">';
}
?>

And then in the affimg.php, you would log the affiliate and then output a 1x1 image (remembering to set the headers). 然后在affimg.php中,您将登录会员,然后输出1x1图像(记住要设置标题)。 The downside is that there is no way to stop an affiliate just simply putting that image in to his page and if the affiliate is using an iframe, the image would still be loaded. 不利之处在于,没有办法仅将图片放到其页面中就停止联盟会员,如果该会员使用的是iframe,该图片仍会被加载。

A better way may be to simply do some tracking. 更好的方法可能是简单地进行一些跟踪。 Rather than just requiring that one page gets visited, change it so that you require two or more using a database to track the ip addresses. 更改页面不仅要访问一个页面,还需要对其进行更改,以便您需要使用数据库来跟踪ip地址的两个或多个页面。

There may be a better way, but then I don't know the exact details. 也许有更好的方法,但是我不知道确切的细节。

First, you can never be sure that a bot/script instead a human "clicks" on an image, this is a fact. 首先,您永远不能确定机器人/脚本会代替人类在图像上“点击”,这是事实。 Secondly, you can make things a bit difficult. 其次,您可能会使事情变得有些困难。 An idea would be: 一个想法是:

Deliver a banner including a unique link that is triggered via a Javascript-click-event, like: 交付包含通过Javascript-click-event触发的唯一链接的横幅,例如:

<a href="#" onClick="window.locatiom.href='http://www.targetsite.com/?token=<yourtokenhere>';"><img src="http://www.targetsite.com/image.jpg" /></a>

Save the token in your database before and give it a expiration time of some minutes. 之前将令牌保存在数据库中,并赋予其几分钟的到期时间。 Then, only count the click if the token is valid later. 然后,仅当令牌在以后有效时才计算点击次数。 So your affiliate has to change the "onClick"-Event or parse the source code to extract the token. 因此,您的会员必须更改“ onClick”事件或解析源代码以提取令牌。

As said, it only makes things more difficult. 如前所述,这只会使事情变得更加困难。 You could also parse your affiliate's site source to see whether there, your banner is "clicked" automatically (which would be very cheeky). 您还可以解析您的会员的网站资源,以查看是否自动“点击”了您的横幅广告(这很厚脸皮)。

Another addition would be to read a cookie on the client side and attach it to the generated link to implement a check if the client has already requested your target site. 另一个补充是在客户端读取cookie,并将其附加到生成的链接上,以检查客户端是否已请求您的目标站点。

Since you can't protect yourself completely from fakes, you can build several little tools like these that increase safety. 由于您无法完全保护自己免受伪造,因此可以构建一些类似的小工具以提高安全性。

HTH 高温超导

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM