Joomla: count Robots
- Details
- Kategorie: Diverse
- Veröffentlicht: Sonntag, 09. Mai 2021 01:08
- Geschrieben von Super User
- Zugriffe: 2346
little hack to count robots (type: Core Hack / Joomla)
ever wanted to know how many real (guest) users are just visting your site?
counting the number of robots is quite simple if you add just a line in the library MetadataManager.php
(this is where the basic data for a new session are set. you find it in libraries/src/Session)
in the function createRecordIfNonExisting
just look for the line $values = array(...) and right before add this 2 lines
if ($user->guest && $this->app->client->robot) // the joomla core returns true if a robot is detected
$user->guest ++; // and then we simply set $user->guest = 2 (normally 1)
* app->client->robot is only available in Jooma 3.7 or newer
now the database entry in the guest column will not be only 0 or 1, but may be 2 if a robot is detected
you can do what you want or your counting modules looks for,
eg. in the whoisonline module guest and members are just count by the db->session data
so if data->guest == 0 counts as a member, and data->guest == 1 counts as a guest
you decide if counting all non-members (data->guest > 0) , or count robots extra (data-guest == 2)
the footer shows an example and also look at the HotorNot Statistic, where just real guests are count