]> git.openstreetmap.org Git - rails.git/blob - script/update-spam-blocks
Implmented diary submit label changing depending on if new or editing
[rails.git] / script / update-spam-blocks
1 #!/usr/bin/env ruby
2
3 require File.dirname(__FILE__) + "/../config/environment"
4 require "generator"
5
6 addresses = User.count(
7   :conditions => {
8     :status => %w(suspended deleted),
9     :creation_time => Time.now - 28.days..Time.now
10   },
11   :group => :creation_ip
12 )
13
14 addresses.each do |address, count|
15   next unless count > 1
16   next if Acl.where(:address => address).exists?
17
18   Acl.create({
19                :address => address,
20                :k => "no_account_creation",
21                :v => "auto_spam_block"
22              }, { :without_protection => true })
23
24   puts "Blocked #{address}"
25 end
26
27 acls = Acl.find(:all, :conditions => {
28                   :k => "no_account_creation",
29                   :v => "auto_spam_block"
30                 })
31
32 acls.each do |acl|
33   next if addresses[acl.address]
34
35   acl.delete
36
37   puts "Unblocked #{acl.address}"
38 end
39
40 exit 0