4 * Description: Blocking bots based on detecting bots/crawlers/spiders via the user agent and http_from header.
6 * Author: Philipp Holzer <admin@philipp.info>
11 use Friendica\Core\Hook;
12 use Friendica\Core\System;
13 use Jaybizzle\CrawlerDetect\CrawlerDetect;
15 require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
17 function blockbot_install() {
18 Hook::register('init_1', __FILE__, 'blockbot_init_1');
22 function blockbot_uninstall() {
23 Hook::unregister('init_1', __FILE__, 'blockbot_init_1');
26 function blockbot_init_1(App $a) {
27 $crawlerDetect = new CrawlerDetect();
29 if ($crawlerDetect->isCrawler()) {
30 System::httpExit(403, 'Bots are not allowed');