ban-quick-editors.pl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (C) 2013–2015 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software: you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation, either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. #
  15. # This file must load before logbannedcontent.pl such that quick
  16. # editors will be logged.
  17. use strict;
  18. use v5.10;
  19. AddModuleDescription('ban-quick-editors.pl', 'Banning Quick Editors');
  20. our ($q, $Now, %RecentVisitors, $SurgeProtection);
  21. *BanQuickOldUserIsBanned = \&UserIsBanned;
  22. *UserIsBanned = \&BanQuickNewUserIsBanned;
  23. sub BanQuickNewUserIsBanned {
  24. my $rule = BanQuickOldUserIsBanned(@_);
  25. if (not $rule
  26. and $SurgeProtection # need surge protection
  27. and GetParam('title')) {
  28. my $name = GetParam('username', $q->remote_addr());
  29. my @entries = @{$RecentVisitors{$name}};
  30. # $entry[0] is $Now after AddRecentVisitor
  31. my $ts = $entries[1];
  32. if ($Now - $ts < 5) {
  33. return "fast editing spam bot";
  34. }
  35. }
  36. return $rule;
  37. }