Skip to content

Conversation

@BrainforgeUK
Copy link
Contributor

Now uses strpos instead of preg_match.

Summary of Changes

In isRobot() use strpos() instead of preg_match() as that is faster.

See https://www.php.net/manual/en/function.preg-match.php#refsect1-function.preg-match-notes

Testing Instructions

A simple test available in this plugin.
bfisrobottest.zip

Install and on enabling the front-end displays the following on success:
Test (false):
Test (true):1
Test (true):1

Actual result BEFORE applying this Pull Request

Robots detected.

Expected result AFTER applying this Pull Request

Robots detected.
Its a big list of robots - possibly a detectable performance improvement,

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@brianteeman
Copy link
Contributor

The list is massively out of date

See #45323

@BrainforgeUK
Copy link
Contributor Author

Agree I was wondering about the best way forward. See comment I've added to #45323

Would moving this big list into a plugin be a first start? e.g.

plg_browserbot_legacy

Can then investigate other bot detectors like this.
https://fingerprint.com/try/bot-detection/

plg_browserbot_fingerprint

Up to site admin to enable the one(s) they want to use.

Add plugin support for robot detection in isRobot method.
@BrainforgeUK
Copy link
Contributor Author

BrainforgeUK commented Nov 5, 2025

Added support for isrobot event in browserbot plugin folder.
Falls through to legacy list if no plugin found.

In future can add browserbot plugins whenever convenient.

Install and enable this plugin to test:
plg_browserbot_test.zip

Invocation:
To emulate a normal user
yourtestsite/index.php?isrobot=0

And to emulate a robot
yourtestsite/index.php?isrobot=1

Legacy isRobot behaviour
yourtestsite/index.php

Refactor isRobot method to check for null return from importPlugin and improve readability.
@ceford
Copy link
Contributor

ceford commented Nov 5, 2025

Could you use in_array()? How would it compare for speed?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46413.

@brianteeman
Copy link
Contributor

As I wrote in the referenced issue we should not be trying to maintain a list of robots ourselves and should be using a well maintained library instead

@BrainforgeUK
Copy link
Contributor Author

As I wrote in the referenced issue we should not be trying to maintain a list of robots ourselves and should be using a well maintained library instead

... The plugin solution opens up the possibility to use any number of free / freemium / paid for libraries. Maybe one plugin could be distributed with Joomla Project like Google Captcha is incluided. Other possibilities left to 3rd party developers.

Not an intended outcome of this pull request I have a long-standing use case of the Browser class where it looks like using this plugin approach is worth investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants