Fraud Clicks are often reason of account suspension. Publishers (like You) so far had limited abilities to protect themselves.
That's why Contextual Tracker delivers special tool called SafeAd that allows to hide ads from users (identified by IP) which executes specified amount of clicks.
There are 2 ways of using SafeAd:
General installation:
Using in PHP:
Include file ct_safead.php located in script directory and call function ct_safe();
bool ct_safead( [sys [, max_clicks ]] );
Function accepts 2 optional arguments - first represents an ad system, second is maximum amount of clicks (default 3).
Returned value is true (1) when user can safely see an ad or false (0), if he already exceeded his click limit.
In case of not passing the system's name global clicks' amount is checked.
Implementations example:
It's easy to understand that code above will show AdSense (fake function show_adsense();) only if user clicked not more than 4 times.
In other case other ads will be showed (fake function show_other_ad();).
Using in JavaScript (JS):
Loading special JS script we receive of PHP function in JS variable ct_safead.
Script arguments are same as for PHP function (sys and max_clicks - read above) but they are passed in URL.
Implementations example:
Code above will hide AdSense ads (2 ways possible, more info in comments).
It's not certainty that such practices are compialance with AdSense TOS, so i would strongly recommend using PHP or redirecting user to another page.
You can test SafeAd on following test pages:
All paths used in code examples assumes that page is one directory below script.
That's why everywhere appears path "./ct". For personal needs it can require modification.
There has to be distinguished clearly that JS path (http) is something different that PHP path (server's internal directory).
BONUS:
If You have small amount of clicks (literally couples per day), in crontab you should paste following line which will refresh file with IP list every hour: