I’m making a hit counter. I have a database and I store the IP and $_SERVER['HTTP_USER_AGENT']; of the visitors. Now I need to add a filter, so I can put away the hits, that are made by bots. I found out, that many bots usually keep some common words in the $_SERVER['HTTP_USER_AGENT']; , so I’s like to make and array of words, that would keep the bot from displaying in the results.
Here is what I have now:
while($row = mysql_fetch_array($yesterday, MYSQL_ASSOC)) {
<– Here I need a code, that would run through an array and check,
if it containts the keywords and if it doesn’t … just count++; –>
}
Also if you know any other way of detecting and removing the bots from the results, I’d be verry thankful. Cheers
Loop through the array of words with
foreachand check if the current word exists in the UA string using strpos():