in reply to Re: Bot vs human User Agent strings
in thread Bot vs human User Agent strings
Thanks...based on this solution and sleeping on it, I've implemented this solution:
open my $fh, '<', "....data/UserAgents/block.dat"; my @agent = <$fh>; close $fh; chomp @agent; my $invalid = grep { $ENV{'HTTP_USER_AGENT'} =~ /$_/i } @agent;
The solution from hippo has made me think, recall and investigate what Apache can do in this situation. However, I decided to do it this way instead of using Apache because it keeps all the logic in the method that processes the page headers. This is where the session cookie is set, so it makes sense (to me) to keep the code there as well. I feel this should be easy to maintain and easy to find.
I am a bit confused by a line in the above code:
Isn't the m operator redundant here or is it doing something subtle that I have overlooked?if ($junk=~m/$badregex/) { print qq~\nSee....?\n~; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Bot vs human User Agent strings
by hippo (Archbishop) on Feb 11, 2024 at 00:02 UTC |