diff --git a/botdetection/botdetection.php b/botdetection/botdetection.php new file mode 100644 index 00000000..ca6109a6 --- /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'); + } +}