-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathblockbots.sh
More file actions
executable file
·24 lines (21 loc) · 846 Bytes
/
blockbots.sh
File metadata and controls
executable file
·24 lines (21 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# +----+----+----+----+
# | | | | |
# Author: Mark David Scott Cunningham | M | D | S | C |
# +----+----+----+----+
# Created: 2014-03-06
# Updated: 2014-07-05
#
#
#!/bin/bash
# RewriteCond %{HTTP_USER_AGENT} 80legs\.com [NC]
# RewriteRule .* - [F,L]
if [[ -z $@ || $1 == '-h' || $1 == '--help' ]]; then
echo -e "\n Usage: blockbot [list of bots]\n"
else
if grep -Eq '^.*Order Allow,Deny.*$' .htaccess; then
sed -i 's/\(^.*Order Allow,Deny.*$\)/\1\nDeny from env=bad_bot/' .htaccess
else echo -e "\nOrder Allow,Deny\nDeny from env=bad_bot\nAllow from All" >> .htaccess; fi
echo -e "\n# ----- Block Bad Bots Section -----\n" >> .htaccess
for x in $@; do echo "BrowserMatchNoCase $x bad_bot" >> .htaccess; done
echo -e "\n# ----- Block Bad Bots Section -----\n" >> .htaccess;
fi