/    Sign up×
Community /Pin to ProfileBookmark

Counting Genuine Views vs Bots

I understand this is a complex issue and there’s no silver bullet so to speak but I’m looking for ideas on how maybe I could improve things.

Following on from my post yesterday, I’m now recording view of an object with the IP and object ID hasn’t been entered into the DB within the last hour,

It works nicely for genuine visitors.

The issue I have is I’m getting ‘bots’ in my DB

I started to block them and I might have blocked some of googles but I’m still getting more and I’ve not even looked at other popular bots. If I was to continue down this path I would end up managing a long list of IP’s.

**As an idea**
Most of my visitors are from 5 or 6 countries as it’s content specific.

Is there a quick and simple way (free) to look-up and IP and confirm what country it’s from? Maybe I’ll only enter these countries?

“`
$ipRanges = array(
array(‘min’ => ip2long(‘64.233.160.0’), ‘max’ => ip2long(‘64.233.191.255’)),
array(‘min’ => ip2long(‘66.102.0.0’), ‘max’ => ip2long(‘66.102.15.255’)),
array(‘min’ => ip2long(‘66.249.64.0’), ‘max’ => ip2long(‘66.249.95.255’)),
array(‘min’ => ip2long(‘72.14.192.0’), ‘max’ => ip2long(‘72.14.255.255’)),
array(‘min’ => ip2long(‘74.125.0.0’), ‘max’ => ip2long(‘74.125.255.255’)),
array(‘min’ => ip2long(‘209.85.128.0’), ‘max’ => ip2long(‘209.85.255.255’)),
array(‘min’ => ip2long(‘216.239.32.0’), ‘max’ => ip2long(‘216.239.63.255’)),
array(‘min’ => ip2long(‘64.18.0.0’), ‘max’ => ip2long(‘64.18.15.255’)),
array(‘min’ => ip2long(‘108.177.8.0’), ‘max’ => ip2long(‘108.177.15.255’)),
array(‘min’ => ip2long(‘172.217.0.0’), ‘max’ => ip2long(‘172.217.31.255’)),
array(‘min’ => ip2long(‘173.194.0.0’), ‘max’ => ip2long(‘173.194.255.255’)),
array(‘min’ => ip2long(‘207.126.144.0’), ‘max’ => ip2long(‘207.126.159.255’)),
array(‘min’ => ip2long(‘216.58.192.0’), ‘max’ => ip2long(‘216.58.223.255’)),

array(‘min’ => ip2long(‘64.68.90.1’), ‘max’ => ip2long(‘ 64.68.90.255’)),
array(‘min’ => ip2long(‘64.233.173.193’), ‘max’ => ip2long(‘64.233.173.255’)),
array(‘min’ => ip2long(‘66.249.64.1’), ‘max’ => ip2long(‘66.249.79.255’)),
array(‘min’ => ip2long(‘216.239.33.96’), ‘max’ => ip2long(‘216.239.59.128’)),
);

$bot = false;
foreach ($ipRanges as $IpRange){
if ($ip <= $IpRange[‘max’] && $IpRange[‘min’] <= $ip) {
$bot = true;
}
}
“`

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@sibertJun 15.2022 — Disclaimer: I have limited experience of bots.

But there is three ways I should look at as a start. Find a way to [Read the Request Header](https://websiteadvantage.com.au/Request-HTTP-Header-Info) or stop them by using [Cloudflare Firewall Rules](https://geekflare.com/cloudflare-firewall-block-bots/) or use [Bot Fight Mode](https://developers.cloudflare.com/bots/get-started/free/). Cloudflare does not only protect, but makes your site faster. There is a free plan.

[url=https://postimages.org/][img]https://i.postimg.cc/d1fPbXCj/firewall.png[/img][/url]
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...