diff --git a/botdetection/botdetection.php b/botdetection/botdetection.php new file mode 100644 index 000000000..ca6109a66 --- /dev/null +++ b/botdetection/botdetection.php @@ -0,0 +1,30 @@ + + * + */ + +use Friendica\App; +use Friendica\Core\Hook; +use Friendica\Core\System; +use Jaybizzle\CrawlerDetect\CrawlerDetect; + +function botdetection_install() { + Hook::register('init_1', 'addon/botdetection/botdetection.php', 'botdetection_init_1'); +} + + +function botdetection_uninstall() { + Hook::unregister('init_1', 'addon/botdetection/botdetection.php', 'botdetection_init_1'); +} + +function botdetection_init_1(App $a) { + $crawlerDetect = new CrawlerDetect(); + + if ($crawlerDetect->isCrawler()) { + System::httpExit(404, 'Bots are not allowed'); + } +}