Hi folks,
We are going to be sponsoring some free wifi access which will launch our site after a user joins the network. Our problem is that we need to hide our adsense ad blocks from those users and show other blocks in their place as google would likely see it as a click fraud attempt.
I have hacked together some php for the block visibility based on some handbook information but wanted to be sure I was on the right track prior to adding it as my php skills are not that strong.
If you could have a look at the code and let me know if this seems ok or if there is a better solution to show/hide blocks based on a range of IP addresses, I'd appreciate it.
Block visibility code to hide adsense:
<?php
$adressestohide = array('192.168.0.1', '192.168.0.2', '192.168.0.3'); // array of IP addresses to hide block from
if (in_array($_SERVER["REMOTE_ADDR"], $adressestohide, true)) {
return FALSE; // Block is hidden
}
else {
return TRUE; // Block is shown
}
?>
Block visibility code to show replacement block:
<?php
$adressestohide = array('192.168.0.1', '192.168.0.2', '192.168.0.3'); // array of IP addresses to show replacement block
return (in_array($_SERVER["REMOTE_ADDR"], $adressestohide);
?>
Thanks a bunch for your help,
Rob