Skip to content

Commit

Permalink
Add admin url for possible spam tracks and spam listeners.
Browse files Browse the repository at this point in the history
  • Loading branch information
sudara committed Jun 3, 2009
1 parent 61aac2d commit 2c5bb08
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/controllers/assets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def register_listen
:listener => current_user || nil,
:track_owner => @asset.user,
:source => @referer,
:user_agent => @agent,
:ip => request.remote_ip
) unless bot?
end
Expand All @@ -289,7 +290,7 @@ def set_user_agent

def prevent_abuse
if bot?
Rails.logger.error "#{@asset.filename} #{@agent} #{request.remote_ip} #{@referer} #{current_user || nil}"
Rails.logger.error "BOT LISTEN ATTEMPT FAIL: #{@asset.filename} #{@agent} #{request.remote_ip} #{@referer} User:#{current_user || 0}"
render(:text => "Denied due to abuse", :status => 403)
end
end
Expand Down
12 changes: 12 additions & 0 deletions app/models/listen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ def self.last_30_days_chart
)
end

def self.count_by_ip
Listen.count(:all, :group => :ip, :conditions => ['created_at > ?',60.days.ago], :order => 'count_all DESC', :limit => 25)
end

def self.count_by_track
Listen.count(:all, :group => :asset, :conditions => ['created_at > ?',60.days.ago], :order => 'count_all DESC', :limit => 25)
end

def self.find_user_by_ip(ip)
Listen.find(:first, :conditions => ['ip = ? AND listener_id IS NOT NULL',ip]).listener rescue nil
end

protected

# iterate through the months
Expand Down
3 changes: 1 addition & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
ActionController::Routing::Routes.draw do |map|
map.resources :groups

map.resources :posts

map.admin 'secretz', :controller => 'secretz'

# manual, ghetto, overriding links
map.rpm_challenge 'rpmchallenge', :controller => 'pages', :action => 'rpm_challenge'
Expand Down
4 changes: 2 additions & 2 deletions public/stylesheets/sass/alonetone.sass
Original file line number Diff line number Diff line change
Expand Up @@ -720,11 +720,11 @@ h1 span#channel_name
:text-align left
:background-color =!silver
:width 100%
.static_content#stats
.static_content#stats, .static_content.stats
:padding 0
:margin 0
:width auto
#statstable
#statstable, .statstable
:width 100%
thead tr
:background transparent url(../images/backgrounds/user_bar.png) repeat-x scroll left top
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/assets_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"",
"Googlebot/2.1 (+http://www.google.com/bot.html)",
"you're momma's so bot..."
"Baiduspider+(+http://www.baidu.jp/spider/) ",
"Baiduspider+(+http://www.baidu.jp/spider/)",
"baidu/Nutch-1.0 "
]

Expand Down

0 comments on commit 2c5bb08

Please sign in to comment.