2015-10-23 19:42:51 +00:00
module JamRuby
class IpBlacklist < ActiveRecord :: Base
attr_accessible :remote_ip , :notes , as : :admin
@@log = Logging . logger [ IpBlacklist ]
2016-02-09 18:58:54 +00:00
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
2015-10-23 19:42:51 +00:00
def self . listed ( remote_ip )
2016-02-09 18:58:54 +00:00
IpBlacklist . where ( :conditions = > " remote_ip = ' #{ remote_ip } ' " ) == 1
2015-10-23 19:42:51 +00:00
end
2015-10-23 20:08:54 +00:00
def self . admin_url
APP_CONFIG . admin_root_url + " /admin/ip_blacklists/ "
end
2015-12-02 22:53:09 +00:00
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
2015-10-23 20:08:54 +00:00
def admin_url
APP_CONFIG . admin_root_url + " /admin/ip_blacklists/ " + id
end
2015-10-23 19:42:51 +00:00
def to_s
remote_ip
end
end
end