Hostname Filtering
| From: | Dan | Date: | Tue, 14 Mar 2006 15:30:09 +0000 |
| Subject: | Hostname Filtering | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231896@lists.php.net to get a copy of this message | ||
I have a few PHP scripts where I log hit to a page i.e. IP and hostname via a look up.
What I want to do is create essentially a blacklist to prevent bots and other hosts and IP from being logged and skewing my stats. My local IP/host and the MSN and Googlebot hits should not be in my stats or at least I can flag them to hide them.
For example:
$blacklist = array(
'*.wavefront.ca',
'*.googlebot.com',
'msnbot.msn.com',
'*.inktomisearch.com',
'68.146.96.245'
);
So lets say I have my host:
$host = 'lj602144.inktomisearch.com';
I want to quickly parse this array and return a simple boolean if I am in the blacklist. I could create a loop and cycle through the array valves and to a regex on each but I was hoping someone would have a more elegant solution.
Thanks,
Dan T