From f1839f23e6b67af8ab6262dbc0ad62a0c45f4999 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sat, 20 Apr 2019 14:15:45 +0200 Subject: [PATCH] New Addon Bot detection --- botdetection/botdetection.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 botdetection/botdetection.php 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'); + } +}