34 lines
942 B
Ruby
34 lines
942 B
Ruby
module JamRuby
|
|
class IpBlacklist < ActiveRecord::Base
|
|
|
|
attr_accessible :remote_ip, :notes, as: :admin
|
|
|
|
@@log = Logging.logger[IpBlacklist]
|
|
|
|
validates :remote_ip, presence: true, uniqueness: true
|
|
|
|
def self.banned(remote_ip)
|
|
IpBlacklist.count(:conditions => "remote_ip = '#{remote_ip}' AND remote_ip not in (select remote_ip from ip_whitelists where remote_ip = '#{remote_ip}')") == 1
|
|
end
|
|
|
|
def self.listed(remote_ip)
|
|
IpBlacklist.where(:conditions => "remote_ip = '#{remote_ip}'") == 1
|
|
end
|
|
|
|
def self.admin_url
|
|
APP_CONFIG.admin_root_url + "/admin/ip_blacklists/"
|
|
end
|
|
|
|
def self.admin_activity_url(remote_ip)
|
|
APP_CONFIG.admin_root_url + "/admin/download_trackers?q[remote_ip_equals]=#{URI.escape(remote_ip)}&commit=Filter&order=id_desc"
|
|
end
|
|
|
|
def admin_url
|
|
APP_CONFIG.admin_root_url + "/admin/ip_blacklists/" + id
|
|
end
|
|
|
|
def to_s
|
|
remote_ip
|
|
end
|
|
end
|
|
end |